Skip to content

incorrect pattern field for openapi #1458

@elee1766

Description

@elee1766

so in my generated openapi schema, i noticed that there was "/" surrounding my regex, which ends up rendering incorrectly in swagger-ui

i traced it to this line in the documentation builder in depictString.

result.pattern = `/${regex.source}/${regex.flags}`;

so it uses the format /${regex.source}/${regex.flags}, however looking here: https://swagger.io/docs/specification/data-models/data-types/#pattern it seems that it just wants ${regex.source}, and oas3/3.1 does not support flags

https://262.ecma-international.org/5.1/#sec-15.10.1 it looks like bnf for regexp here does not include the wrapping / and flags

i think the right answer here is to just change this line to result.pattern = `${regex.source}` // result.pattern = regex.source ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions