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

Load servers and info from yaml files #285

Open
information-security opened this issue Oct 20, 2021 · 2 comments
Open

Load servers and info from yaml files #285

information-security opened this issue Oct 20, 2021 · 2 comments
Labels
pinned Issues that will not be automatically closed

Comments

@information-security
Copy link

I am not sure if this is an indented behavior or bug, so please feel free to re-label this to bug report.

Is your feature request related to a problem? Please describe.
I am not able to read a few parts of the spec from yaml files. For example (servers and info). But It is great that I can do this with other parts like tags and components.

Describe the solution you'd like
I want to split the spec into multiple yaml files. For instance, servers.yaml, tags.yaml, info.yaml, components.yaml, etc.
And afterward, I shall be able to initialize the SwaggerJSDoc like below.

const options: swaggerJSDoc.OAS3Options = {


	apis       : [ `${rootPath}/src/routes/**/*.js`, `${rootPath}/src/docs/swagger/*.yaml` ]
};

const swaggerSpec = swaggerJSDoc.default(options);

Describe alternatives you've considered
I am currently keeping the info and servers parts of the spec in a json file and then load it into the SwaggerJSDoc constructor.

const options: swaggerJSDoc.OAS3Options = {

	definition : config.swaggerDefinition as swaggerJSDoc.OAS3Definition,

	apis       : [ `${rootPath}/src/routes/**/*.js`, `${rootPath}/src/docs/swagger/*.yaml` ]
};

const swaggerSpec = swaggerJSDoc.default(options);

Additional context
N/A

@daniloab daniloab added the pinned Issues that will not be automatically closed label Oct 20, 2021
@daniloab
Copy link
Collaborator

Hi @information-security

Can you provide a repo where you reproduce the error related above?

@information-security
Copy link
Author

information-security commented Oct 20, 2021

Hi dear @daniloab

I have prepared a repo to reproduce the issue.

How to reproduce:

  1. Clone the repo
  2. yarn install
  3. yarn start
  4. Go to http://localhost:3000/docs
  5. You would see that info and servers are not loaded/parsed while tags and components/schemas are.

If you set loadFromYaml variable (Line 9) to false, then it loads the servers and info from the config file passed to the constructor.

Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Issues that will not be automatically closed
Projects
None yet
Development

No branches or pull requests

2 participants