Specification
Specification⚓︎
If you need the complete Specification, go to http://127.0.0.1:8000/openapi/openapi.json
info⚓︎
star-openapi provide Swagger UI, Redoc, RapiDoc, RapiPdf, Scalar and Elements interactive documentation.
Before that, you should know something about the OpenAPI Specification.
You can use a dictionary to provide the info parameters: title, version... , more information sees the OpenAPI Specification Info Object.
1 2 3 4 5 6 7 8 9 10 | |
run it, and go to http://127.0.0.1:8000/openapi, you will see the documentation.
security_schemes⚓︎
There are some examples for Security Scheme Object, more features see the OpenAPI Specification Security Scheme Object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
First, you need to define the security_schemes and security variable:
1 2 3 4 5 6 7 8 9 10 | |
Second, add pass the security to your api, like this:
1 2 3 | |
result:
doc_ui⚓︎
You can pass doc_ui=False to disable the OpenAPI spec when init OpenAPI.
1 | |
You can also use doc_ui in endpoint or when initializing APIRouter.
1 2 3 4 5 6 7 8 9 10 | |
servers⚓︎
An array of Server Objects, which provide connectivity information to a target server. If the server's property is not provided, or is an empty array, the default value would be a Server Object with an url value of /.
1 2 3 4 5 6 7 | |
external_docs⚓︎
Allows referencing an external resource for extended documentation.
More information to see External Documentation Object.
1 2 3 4 5 6 7 | |
openapi_extensions⚓︎
While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. See Specification Extensions.
It can also be available in every api, goto Operation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
validation error⚓︎
You can override validation error response use validation_error_status, validation_error_model
and validation_error_callback.
- validation_error_status: HTTP Status of the response given when a validation error is detected by pydantic. Defaults to 422.
- validation_error_model: Validation error response model for OpenAPI Specification.
- validation_error_callback: Validation error response callback, the return format corresponds to
the validation_error_model. Receive
ValidationErrorand returnStarlette Response.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |

