Initial commit
This commit is contained in:
17
skills/api-design-standards/reference/openapi.md
Normal file
17
skills/api-design-standards/reference/openapi.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# OpenAPI Customization
|
||||
|
||||
**Custom OpenAPI schema with security.**
|
||||
|
||||
```python
|
||||
def custom_openapi(app):
|
||||
openapi_schema = get_openapi(title=app.title, version=app.version, routes=app.routes)
|
||||
openapi_schema["components"]["securitySchemes"] = {
|
||||
"BearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"}
|
||||
}
|
||||
openapi_schema["security"] = [{"BearerAuth": []}]
|
||||
return openapi_schema
|
||||
|
||||
app.openapi = lambda: custom_openapi(app)
|
||||
```
|
||||
|
||||
Access docs at `/docs` (Swagger UI) or `/redoc` (ReDoc).
|
||||
Reference in New Issue
Block a user