cc @dhmlau
Description / Steps to reproduce / Feature proposal
import {model, property, DateType, Entity} from '@loopback/repository';
@model()
class Test extends Entity {
@property()
date: DateType
};
Current Behaviour
Since DateType is not a class decorated by @model, the generated OpenAPI spec doesn't generate schema for it in components.schemas
Expected Behaviour
automatically generate a schema entry in components.schemas for it.
Some proposal:
- Discovering datatype and generating schema/definition could happen when generate
jsonDef or oai3Spec, which one is better?
Acceptance Criteria:
// Given a class with properties in Loopback types
@model
class Test {
@property
date: Date
@property
text: Buffer
}
// The generated schema for model Test should be
{
schemas: {
Test: {
type: 'object',
properties: {
date: {type: 'string', format: 'date'},
text: {type: 'string', format: 'buffer'}
}
}
}
}
- For each Loopback type, we can either map it to a simple schema like
schema: {type: string, format: 'date'}
or a schema reference
components: {
schemas: {
Date: {type: string, format: 'date'}
}
}
People who works on this story can decide per type which approach is better. Types in scope:
Nice to have:
cc @dhmlau
Description / Steps to reproduce / Feature proposal
Current Behaviour
Since
DateTypeis not a class decorated by@model, the generated OpenAPI spec doesn't generate schema for it incomponents.schemasExpected Behaviour
automatically generate a schema entry in
components.schemasfor it.Some proposal:
jsonDeforoai3Spec, which one is better?Acceptance Criteria:
For a model property in Loopback type(would be the types in
@loopback/types), we automatically generate the openapi spec for it.For example:
or a schema reference
People who works on this story can decide per type which approach is better. Types in scope:
Nice to have: