Open idesoto opened 3 years ago
I had a very similar issue. At least it is easy to work around. See the Formats section in README. Here is what I did:
class UriReferenceFormatter: def validate(self, value) -> bool: return bool(re.match(r"(?:\/#\?+)+$", value)) def unmarshal(self, value): return value custom_formatters = { 'uri-reference': UriReferenceFormatter()
Sorry, I couldn't get python to display correctly as code, so I just pasted as text
This now exists in jsonschema
and is enabled by default in openapi-core
.
I believe this is resolved and could be closed.
I have an OpenAPI Schema that I'm generating from a Django (a python web framework) using a library called drf-spectacular. Fields that contain a URL are generated as a "type: string" with "format: uri" by this library. When validating with openapi-core I get this error:
Though
uri
is not defined as a built-in format in the OpenAPI spec, according to the specs format can contain other values, and unrecognized formats should not be validated.So I think openapi-core should either support the
uri
format or ignore it, but not fail validation.