Is there a way to hide some fields from OpenAPI specs?
See original GitHub issueFirst 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.
- After submitting this, I commit to one of:
- Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
- I already hit the “watch” button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
- Implement a Pull Request for a confirmed bug.
Example
Here’s a self-contained, minimal, reproducible, example with my use case:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root(hidden_param=Query(None, description="This parameter should not be visible in OpenApi specs")):
if hidden_param:
return {"Hello": "Master!"}
else:
return {"Hello": "World"}
Description
I’d like to have some request parameters (query or body ones) to be available in the python code, but to be hidden from the OpenAPI specs. Wonder if it is possible to do?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:23
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Hide a Request Field in Swagger API
A quick and practical guide to hiding a request field in Swagger UI.
Read more >How to hide a field in OpenApi 3.0.3 - swagger
I created a swagger containing a get and a put, where in the first I call an element ("MyCar") and in the second...
Read more >OpenAPI 3 Library for spring-boot
For custom path of the swagger documentation in HTML format, add a custom springdoc property, in your spring-boot configuration file: . # ...
Read more >How to automatically hide fields from a flow in Jestor
Focus on what matters. This automation allows you to hide fields according to conditions of your choice. Limit the view of the least ......
Read more >How to hide some APIs from swagger UI?
Which Swagger library do you use to generate the documentation? Should the API be hidden to everyone or based on some condition?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmm, interesting…
I guess we could have a parameter
include_in_schemaforQuery,Body, etc, something like:BTW, if you want to selectively remove or alter things from the schema for a Pydantic model you can already do that with
schema_extra: https://pydantic-docs.helpmanual.io/usage/schema/#schema-customizationIt may also be useful with
Headerto hidex-forwarded-forfrom the documentation for example, when FastAPI is used behind a reverse proxy.