davishmcclurg / json_schemer

JSON Schema validator. Supports drafts 4, 6, 7, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1.
MIT License
408 stars 64 forks source link

OpenApi 3.1 schema validator does not handle variables in server urls #158

Closed ekzobrain closed 1 year ago

ekzobrain commented 1 year ago

Attached file gives an error: value at /servers/0/url does not match format: uri-reference While according to OpenApi docs it's a valid url with variable: https://spec.openapis.org/oas/v3.1.0#fixed-fields-3 OpenApi 3.0 validator does not seem to have this problem.

oas-amocrm.json

davishmcclurg commented 1 year ago

Interesting—OpenAPI validation uses their schema, which specficies uri-reference: https://github.com/OAI/OpenAPI-Specification/blob/6627c32921a341b2a7001fd1cf9f757b8b728fd1/schemas/v3.1/schema.json#L171

But I don't think using variables (in brackets) makes for a valid uri-reference (I also checked https://www.jsonschemavalidator.net/):

>> JSONSchemer.schema({ 'format': 'uri-reference' }).valid?('https://{subdomain}.amocrm.ru')
=> false

I'll dig into this more later, but here's what I've found so far:

davishmcclurg commented 1 year ago

I opened a pull request to change the format in the upstream schemas.

davishmcclurg commented 1 year ago

Temporary fix: https://github.com/davishmcclurg/json_schemer/pull/161

ekzobrain commented 10 months ago

This also fixed a problem with IDNs. "uri-reference" doesn't not allow those, so at least "iri-reference" should have been used instead.