Skip to content
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(api-extension): add support for open api extensions via decorator (#195) #536

Merged

Conversation

tomchinery
Copy link
Contributor

This commit adds support for Open API Extensions via a @APIextension decorator.
Usage:

@ApiExtension(<extensionName>, <extensionPropertyObject>)

Example:

@ApiExtension('x-foo', { hello: 'world' })

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: Solves #195

What is the new behavior?

@ApiExtension('x-foo', { hello: 'world' })

Adds an extension to the Swagger Specification:
Screenshot 2020-01-30 at 08 36 45

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

This commit adds support for Open API Extensions via a @APIextension decorator. 
Usage: 
```
@APIextension(<extensionName>, <extensionPropertyObject>)
```
Example:
```
@APIextension('x-foo', { hello: 'world' })
```
@tomchinery tomchinery changed the title feat(api-extension): add support for open api extensions via decorator feat(api-extension): add support for open api extensions via decorator (#195) Jan 30, 2020
@andreoav
Copy link
Contributor

andreoav commented Feb 4, 2020

@kamilmysliwiec Do you know when you can make this PR available?

@kamilmysliwiec
Copy link
Member

@tomchinery thank you! Would you like to create a PR to the docs as well?

@tomchinery
Copy link
Contributor Author

tomchinery commented Feb 21, 2020

@kamilmysliwiec

@tomchinery thank you! Would you like to create a PR to the docs as well?

Sure, will do so now!

@kamilmysliwiec
Copy link
Member

Amazing, thank you @tomchinery!

@tomchinery
Copy link
Contributor Author

@kamilmysliwiec The docs PR is pushed up here: nestjs/docs.nestjs.com#1021.

Let me know if there's anything else needed. Thanks!

@kamilmysliwiec kamilmysliwiec merged commit c6067c6 into nestjs:master Feb 23, 2020
@kamilmysliwiec
Copy link
Member

Thank you!

@elizabetht
Copy link

elizabetht commented Mar 3, 2021

@tomchinery @kamilmysliwiec Thanks for adding this support for api extensions to swagger docs. How can I add multiple ApiExtensions? My company's swagger validation requires that I add 4 different x-foo: foo, x-bar: baz, x-something: somethingelse, x-ping: pong to my swagger specs under each path definition. But with this extension, I am able to only add only one api extension. I did the following but only the first one got picked up.

@ApiExtension("ping", "pong")
@ApiExtension("foo", "bar")

@kamilmysliwiec
Copy link
Member

@elizabetht Please create a separate issue and share a minimum reproduction repository 🙌

@nestjs nestjs locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants