-
First Check
Commit to Help
Example Codeclass Foo(BaseModel):
passDescriptionI'm looking for a way to override the '$ref' field of a model so that I can reference an external schema. The schema is hosted on a different server, as the model is shared between multiple micro-services. I have a pydantic model say class Foo(BaseModel):
passAnd I would like it to reference the schema at https://example.com/api/v1/openapi.json#/components/schemas/Foo Operating SystemLinux Operating System DetailsNo response FastAPI Version0.73 Python Version3.6.13 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Answering myself:
class Foo(BaseModel):
class Config:
def schema_extra(s):
s.clear()
s["$ref"] = "https://example.com/api/v1/openapi.json#/components/schemas/Foo" |
Beta Was this translation helpful? Give feedback.
Answering myself: