question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way of updating the generated Swagger spec?

See original GitHub issue

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn’t find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google “How to X in FastAPI” and didn’t find any information.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

app = FastAPI()
app.openapi_version = "3.1.0"

Description

Hi, we have an internal tooling of linting the generated swagger (aka, OpenAPI) doc, which requires the API spec to follow 3.1.0. However, the current generated version is 3.0.2.

I used the above code to update it to 3.1.0, and it works. 😄

However, it looks like I am hard coding the version number, rather than generating with the real v3.1.0 spec, so I wonder is there a way to update the internal swagger spec version?

Thanks 😄

Operating System

Windows

Operating System Details

No response

FastAPI Version

0.65.2

Python Version

3.8.8

Additional Context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
tiangolocommented, Nov 7, 2022

Thanks! I’m very glad you have liked it like that! 😁😊 And thanks for coming back to close the issue.

Also thanks @iudeen for the help! 🍰

2reactions
tiangolocommented, Nov 7, 2022

Hey there! Yep, differences are but too big in the specs. And in fact, FastAPI does a couple of things a tiny bit more compatible with 3.1.0.

The only reason why I haven’t updated it is because Swagger UI breaks. But once they support it I’ll be able to update the generated version.

For now, you should be mostly fine by simply overriding it. I know it feels weird, but it shouldn’t be too problematic if at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing your auto-generated Swagger Definitions in 1.5.x
The extension annotation allows you to add extension properties to a Swagger definition. It is currently supported within the @ApiOperation, @ ...
Read more >
API Documentation Made Easy with OpenAPI & Swagger
Swagger Inspector is an easy to use developer tool to quickly execute any API request, validate its responses and generate a corresponding OpenAPI...
Read more >
Configuration - Swagger Documentation
The swagger-config.yaml in the project root directory, if it exists, is baked into the application; configuration object passed as an argument to Swagger...
Read more >
Swagger Codegen Documentation
Swagger Codegen Documentation. The Swagger Codegen is an open source code-generator to build server stubs and client SDKs directly from a Swagger defined ......
Read more >
Improve Your API Documentation Workflow with Compare ...
Or, if you are someone that's following a "code first" approach to Swagger — which means having to use annotations to generate the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found