Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render pattern of string in array of strings #2358

Closed
janholusa opened this issue Jul 18, 2023 · 3 comments · Fixed by #2438
Closed

Render pattern of string in array of strings #2358

janholusa opened this issue Jul 18, 2023 · 3 comments · Fixed by #2438
Assignees

Comments

@janholusa
Copy link

janholusa commented Jul 18, 2023

Current behavior
Currently, when there is need of array of strings with regex pattern, e.g.

"MySampleListOfStrings": {
  "type": "array",
  "description": "Some Fancy List of strings with defined pattern which is sadly not visible",
  "items": {
    "type": "string",
    "pattern": "^OMG Nobody can see me regex[0-9]$"
  }
},

Pattern itself is not generated:
image

Solution proposal
Something like this would be good
image

Maybe with brackets, to indicate it is in array.
image

btw currently it is possible to generate these two samples by using invalid schema when pattern is defined for array.

"MySampleListOfStrings": {
  "type": "array",
  "pattern": "^OMG Nobody can see me regex[0-9]$",
  "description": "Some Fancy List of strings with defined pattern which is sadly not visible",
  "items": {
    "type": "string"
  }
},
@romanpryshliak
Copy link

romanpryshliak commented Jul 26, 2023

Hi @janholusa,

What version of an OpenAPI specification are you using (2.0, 3.0.0, 3.1.0, etc.)?

@janholusa
Copy link
Author

Hi @romanpryshliak ,
I am using "openapi": "3.0.0",.

@UBNT-Peli
Copy link

Unfortunately this bug is still not fully fixed:

  • when only pattern is defined it still not render it
macList:
  type: array
  description: MAC address list
  items:
    type: string
    pattern: ^([0-9a-f]{2}:){5}[0-9a-f]{2}$
  • when pattern and minLength/maxLength is defined, it works properly
macList:
  type: array
  description: MAC address list
  items:
    type: string
    pattern: ^([0-9a-f]{2}:){5}[0-9a-f]{2}$
    minLength: 17
    maxLength: 17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants