routing-controllers-openapi
routing-controllers-openapi copied to clipboard
controllers field is not being used
When generating swagger specifications, the controllers fields in RoutingControllersOptions is actually ignored
Metadata information is taken from a global variable.
My problem is that I would like to generate 2 separate swagger for 2 different sets of controllers, but they get merged as I am not able to separate them using the controllers field
Code to reproduce:
import { v1Controllers } from './controllers/http/v1';
v1Controllers;
export function generateV1API(): OpenAPIObject {
const v1ApiOptions: RoutingControllersOptions = {
controllers: [],
routePrefix: '/v1',
defaultErrorHandler: false,
validation: {
whitelist: true,
},
defaults: {
// with this option, null will return 204 by default
nullResultCode: 204,
// with this option, void or Promise<void> will return 204 by default
undefinedResultCode: 204,
},
};
Even with an empty controllers array [], the controllers are added to the result OpenAPIObject
+1
Currently there is no way to document a 204 ONLY response.
e.g.
@ResponseSchema(undefined, { statusCode: 204 }) // error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'string | Function'.
Workaround:
@OpenAPI({ responses: { "204": { description: "No content" } } })
But both 200 and 204 are displayed ⬇️

Looks like I'm having the same issue as well, but there's no solution yet. I have two sets of APIs, one open to internal members and one open to external members, and I want to generate two different sets of API documents for different target users. What is your final solution?