-
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
feat: adds several convenience decorators #4406
Conversation
This branch adds the following openapi convenience decorators - @deprecated - @tags - @response This branch adds the following features: - creates a `MethodMultiDecoratorFactory`, allowing multiple uses of the same decorator per method. - adds support for the schema keywords 'allOf', 'anyOf', 'oneOf', and 'not' in resolving schemas with the 'x-ts-type' extension - adds a `get-dist-file` to build as a utility to make it easier to debug a unit test file directly in vscode.
Looks like some stuff left over from a bad |
…-next into feature/more-decorators
@mschnee Thank you for the contribution. To make the review process easier, I suggest that we break down this PR into smaller ones and land them incrementally. For example, the 1st PR can be the one to add MethodMultiDecoratorFactory. |
@raymondfeng Sure, I can get that started today. |
@mschnee, thanks for breaking up the PRs into smaller ones. In order to avoid confusion and to avoid people reviewing this one, is it ok if you close this PR? Thanks! |
Done! Thanks for all the fast feedback. |
Warning
This PR is incomplete- I am issuing it to request a preliminary round of feedback.
There are a bunch of concepts involved here that I don't entirely grok- such as the specific implementations of the
DecoratorFactories
, and a couple logical decisions that may be incorrect due to my amateur understanding of the OpenAPI specification.Implements #4300
This branch adds the following openapi convenience decorators
@deprecated()
to a class or method@tags(tagNames: string [])
to a class or method@response(code: number, spec: ModelOrSpec, options?: {contentType: string, description: string})
to methods onlyThis branch adds the following features:
MethodMultiDecoratorFactory
, allowing multiple uses of thesame decorator per method, see the
@response()
decorator.'not' in resolving schemas with the 'x-ts-type' extension
get-dist-file
script topackages/build
as a utility to make it easier todebug a unit test file directly in vscode, see
Debug Current Test File" in
.vscode/launch.json`Examples
The following TypeScript code:
The following typec
Will result in the following json:
This PR is missing the following
@description()
decoratorThis PR does NOT implement the following
@response()
, use the response metadata to hint at the intended response code based on the returned object, or the thrown error, e.g. when a method is decorated as@response(401, SomeAuthError)
, then returning or catchingSomeAuthError
should hint that the response code should be a401
instead of a500
, without requiring the developer to explicitly set the response code by injecting theResponse
object.This PR has the following missing features or bugs:
reduceSpecContent
- does not check if the schema already exists from an existing@op
or@api
definition. It should check if there is an existinganyOf
/allOf
/oneOf
keyword. What happens next is kind of a question: if there is no keyword block, the existing content should be added into ananyOf
, if there is an existinganyOf
block, it should be used. If there's an existingallOf
oroneOf
block... what happens next is kind of undefined.examples
from the@response()
decorator options.Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated