You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Swagger Data Types documentation for the pattern keyword (https://swagger.io/docs/specification/data-models/data-types/#pattern) specifies that the format used should follow the ECMA 262 format. This format is /pattern/flags. However, in the example a few lines below, you use a different format (pattern: '^\d{3}-\d{2}-\d{4}$').
This opens up for a lot of problems, people writing the yaml files according to your example, but the code generators require the ECMA 262 format (I have only checked with the csharp och python code generators, however the java generator seems to accept it), and if the format is wrong, the generators simply throws an exception about the wrong format being used.
There are a lot of (open) issues here about this problem.
The "fun" part is that while the csharp generator throws an exception if the wrong format is used, it doesn't generate any code that actually use the pattern...
Fixing the format to use /pattern/ in the yaml file stops the csharp generator from throwing an exception.
The text was updated successfully, but these errors were encountered:
As explained in OAI/OpenAPI-Specification#1985, pattern is supposed to contain a regular expression body such as ^[A-Za-z0-9]+$ or ^\d{3}-\d{2}-\d{4}$, rather than a regex literal such as /pattern/flags.
@hkosova, ahh, thanks for that! There were too many hits when I searched so couldn't really read through them all.
The problem I (and many others) have is that several of the code generators require the /pattern/flags format, since they throw exceptions if that format isn't used.
Hi,
The Swagger Data Types documentation for the pattern keyword (https://swagger.io/docs/specification/data-models/data-types/#pattern) specifies that the format used should follow the ECMA 262 format. This format is /pattern/flags. However, in the example a few lines below, you use a different format (pattern: '^\d{3}-\d{2}-\d{4}$').
This opens up for a lot of problems, people writing the yaml files according to your example, but the code generators require the ECMA 262 format (I have only checked with the csharp och python code generators, however the java generator seems to accept it), and if the format is wrong, the generators simply throws an exception about the wrong format being used.
There are a lot of (open) issues here about this problem.
The "fun" part is that while the csharp generator throws an exception if the wrong format is used, it doesn't generate any code that actually use the pattern...
Fixing the format to use /pattern/ in the yaml file stops the csharp generator from throwing an exception.
The text was updated successfully, but these errors were encountered: