-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spike: simplify requestBody annotation with schema options #2654
Comments
JsonSchemaOptions
Update: According to requestBody spec, different content types could have different schemas, this is why taking a single type and its options like @post('/') createTodo(@requestBody(Todo, {exclude: ['id']}) todo: ExcludeKeys<Todo, 'id'>) {} could not handle more complicated cases, even though it's the concisest signature. The other proposal {
schema: {
'x-ts-type': Order,
'x-ts-type-options': {
partial: true,
excludes: []
}
} looks more declarative than calling
is still valid. So I am proposing create some sugar apis like |
The PoC of new proposal is created in draft PR #3466 Follow up stories see: |
This is a follow-up for the discussion started in #2082, #2152 and the related issues.
In #2631, we are introducing a new function
getModelSchemaRef
that can be used to obtain OpenAPI schema for a model in a configurable way. Example use:Eventually, we plan to implement the following schema generator options:
includeRelations
in Allow controllers to provide definitions of models referenced in operation spec #2629partial
in Emit schema with all model properties optional #2652exclude
in Emit schema excluding certain model properties #2653The current approach is very verbose. Compare the example above with a controller method that uses default options:
In this spike, we should research different options for simplifying request-body definitions requiring custom schema options.
Few examples to get started:
In Partial update (PATCH) over REST #1722 (comment), @raymondfeng proposed:
This addresses only how to provide schema options when using
x-ts-type
extension. It does not address the problem of too complex spec required by@requestBody
decorator.In Partial update (PATCH) over REST #1722 (comment), @bajtos proposed a different solution:
Acceptance criteria
Partial
#1179, fix: change service generator's ds to uppercase #2125, etc./_SPIKE_.md
document explaining what options you considered, what were pros and cons, how and why did you pick the winner. Include a list of follow-up stories needed to implement the proposed solution.The text was updated successfully, but these errors were encountered: