swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Support setting the openapi version in DocumentBuilder

Open doblinger-extron opened this issue 1 year ago • 4 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

When generating OAS docs for my service, the swagger-ui editor returns errors for some of the nested objects.

The error: allOf must be a non-empty array of schemas. image

If I change the openapi version to 3.1.0, the errors disappear.

Describe the solution you'd like

I'd like to be able to set the openapi version through a DocumentBuilder set function

const config = new DocumentBuilder()
    .setOpenAPIVersion('3.1.0')
    .setTitle('Cats example')
    .setDescription('The cats API description')
    .setVersion('1.0')
    .addTag('cats')
    .build();

Or maybe a better option would be to produce the correct version of OAS automatically

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

I'd like to be able to generate OAS documentation that does not contain errors in the Swagger editor.

doblinger-extron avatar Mar 27 '23 14:03 doblinger-extron

Why has this not been merged yet? https://github.com/nestjs/swagger/pull/2516

Releef avatar Aug 14 '23 11:08 Releef

Would you like to create a PR for this?

kamilmysliwiec avatar Aug 28 '23 08:08 kamilmysliwiec

did this ever make it into the codebase ?

jmls avatar Oct 20 '23 08:10 jmls

@doblinger-extron @jmls I do the following to update open API version

SwaggerModule.setup(
    'api',
    app,
    { ...document, openapi: '3.1.0' })

mortezakarimi avatar Mar 25 '24 16:03 mortezakarimi