G’day everyone,
We are looking at having types something like this:
module Types
include Dry.Types()
Email = self::String.meta(
json_schema: {
description: "An email address",
example: "person@example.com",
}
)
end
Which gets put into a schema like this:
schema = Dry::Schema.JSON do
required(:email).filled(Types::Email)
end
And then converted into JSON schema including the metadata:
Dry::Schema.load_extensions(:json_schema)
schema.json_schema #=>
{
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "An email address",
"example": "person@example.com"
}
},
"required": [
"email"
]
}
To be included in an OpenAPI document.
Having a quick dig through dry-schema, it appears that the type metadata is not carried across to the schema, so there is no simple way to include it in the JSON Schema output. Does that sound correct?
Any ideas how we could achieve this?