Supporting custom types #2944
Replies: 2 comments
-
OpenAPI 3.1 or newer uses JSON Schema (draft 2020-12) spec to define schemas. The
If If you want to specify some data type that has some semantics behind it, you may want to use If pre-defined data types are not enough for you, you are allowed to use your own data types, but there are no guarantees implementations you use will support them as you expect. Valid example of a schema with {
"type": "string",
"format": "email"
} It's also possible to reuse schemas with You may define your schema once in Components Object: {
"openapi": "3.1.0",
"components": {
"schemas": {
"Email": {
"type": "string",
"format": "email"
}
}
}
} And then reuse it inside your OpenAPI document with {
"primaryEmail": { "$ref": "#/components/schemas/Email" }
} |
Beta Was this translation helpful? Give feedback.
-
This was answered, and |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm new to OpenAPI and we're using for a project where we have our custom data types.
I would like to know if it would be possible to use an UI implementation of the OpenAPI and
have it render the custom data type. For example, I could use this json,
{ "varName":{ "type": "customDataType" } }
and have it rendered as it it were a string or number or any of the other supported types by OA.
P.S.: We could use objects but we would still have to fall back to the OpenAPI data types, which is something we want to avoid.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions