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

controllers field is not being used #97

Open
tmouchart opened this issue Dec 16, 2021 · 3 comments
Open

controllers field is not being used #97

tmouchart opened this issue Dec 16, 2021 · 3 comments

Comments

@tmouchart
Copy link

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

@talbSE
Copy link

talbSE commented Sep 4, 2022

+1

@kenberkeley
Copy link

kenberkeley commented Dec 15, 2022

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 ⬇️

image

@sxlvalue
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants