-
Notifications
You must be signed in to change notification settings - Fork 480
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/define global responses #1612
base: master
Are you sure you want to change the base?
Conversation
Enables defining global responses which are inherited by all server routes. fixes nestjs#884
This reverts commit eb9c45c.
Any updates on this? |
Looks like this is passing. Is it possible to merge it? This would be very helpful to have. @kamilmysliwiec |
@kamilzki, @kamilmysliwiec Maybe we will make a merge or we are waiting for something else? |
@skiryuk When I created the PR, I tried to contact with @kamilmysliwiec, but unfortunately, I've never got any response. |
up |
Is it possible to merge? @kamilmysliwiec |
Ran into a scenario where this would be useful. Any chance this could be merged? |
I also have a need for this. AFAIK currently there's no way to directly modify the In that case, this is very similar to how currently the security methods work, there's the individual ones that add elements to Also, another difference here is that responses in // ResponsesObject comes from lib/interfaces/open-api-spec.interface.ts
const myResponse: ResponseObject = {
description: "My description",
headers: {
// ...
},
content: {
"application/json": {
// ...
}
// ...
},
links: {
// ...
}
}
new DocumentBuilder()
.addResponse(response, "MyResponseName")
.addGlobalResponse("MyResponseName", "4XX") So the resulting OpenAPI document would be something like this: {
"openapi" : "3.0.0",
"paths" : {
"/some/path" : {
"get" : {
"operationId" : "getThing",
"responses" : {
"200" : {
"description" : "This is a previously defined response",
"content" : {
"application/xml" : {
"schema" : {
"$ref" : "#/components/schemas/SomePreviouslyDefinedResponse"
}
}
}
},
"4XX" : {
"$ref" : "#/components/responses/MyResponseName"
}
}
}
}
},
"components" : {
"responses" : {
"MyResponseName" : {
"description" : "My description.",
"headers": {
// ...
},
"content" : {
"application/json" : {
// ...
}
},
"links": {
// ...
}
}
}
}
} Just my two pennies' worth, it would be a shame to see a SECOND pull request go stale 😅 |
Any evolution in this PR? |
I'm sorry to bother you, but I would like this pull request to be merged. For example, in the Components Object section of Swagger's official documentation Components Object holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. This paragraph comes from the OpenAPI specification v3.1 released in 2021, but this year is already 2024, this feature can not be used in nest, personal feeling will not be a little outdated? I want to push forward with this PR merger, and it's my request alone. please. |
Kinda need it too, used to do it in java and the initial PR is 3 years old :/ |
I would also push for this, becaus the |
Yeah agree, I am looking for the same functionality for |
Any update? |
Enables defining global responses which are inherited by all server routes.
fixes #884
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #884
What is the new behavior?
DocumentBuilder.addResponse
has been added as a way to specify API responses globally. All server routes are then by default extending global responses.Does this PR introduce a breaking change?
Other information