Query String Parameter Validation - RegEx

7 views
Skip to first unread message

Jerry Thome

unread,
Jun 13, 2018, 9:05:19 AM6/13/18
to Swagger
Is 'pattern' supported for quey string parameters?  I'm using the below snippet in a project.  It seems well formed, but my OpenAPI3RouterFactory validation handler (3.5.2.CR1) doesn't seem to honor pattern.

...
paths:
  /v1/widget:
    get:
      operationId: generateWidget
      parameters:
      - name: url
        in: query
        schema:
          type: string
          pattern: '^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)$'
        required: true  
        example: 'https://www.google.com'
...


I have another example where the pattern is '^[LMQH]$' and a value of Z doesn't trip the validation either.

Thanks.
Reply all
Reply to author
Forward
0 new messages