swagger-api / swagger-editor

Swagger Editor
https://editor.swagger.io
Apache License 2.0
8.8k stars 2.24k forks source link

Swagger editor reports 'should match format "regex"' #5171

Open AstenorOfAlembria opened 4 weeks ago

AstenorOfAlembria commented 4 weeks ago

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3 info: title: Real Estate API version: 1.0.0 paths: /realEstateSites: get: summary: Get Real Estate Sites operationId: getRealEstateSites responses: '200': description: OK content: application/json: schema: type: object properties: realEstateSite: type: object properties: timeZone: $ref: '#/components/schemas/TimeZone' components: schemas: TimeZone: description: Time zone as declared in the TZ database in the form "Area/Location". type: string minLength: 3 maxLength: 44 pattern: '^(?n)((?!Etc\/GMT)[A-Z][A-Za-z]{0,13}\/[A-Z][A-Za-z]{0,13})(\/[A-Z][A-Za-z_]{0,13})?|(Etc\/GMT[+-]\d{1,2})$' example: Europe/Paris

Describe the bug you're encountering

Swagger editor does not recognize the valid regex (checked with https://regex101.com/) provided as the 'pattern' of TimeZone

To reproduce...

As soon as I put the YAML in the Swagger editor, it reports

Structural error at components.schemas.TimeZone.pattern
should match format "regex"
format: regex
Jump to line 30

Expected behavior

No error

Screenshots

image

Additional context or thoughts

It seems the (?n) is not recognized On the web, I saw that the (?i) is not recognized either

(?n) match the remainder of the pattern with the following effective flags: gmn n modifier: no capture. All capturing groups () are instead treated as if they were non-capturing groups (?:). (?i) match the remainder of the pattern with the following effective flags: gmni i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])