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

Properties with RegEx patterns containing a unicode property escape renders braces in example values #10112

Open
richard-collette-precisely opened this issue Aug 29, 2024 · 0 comments

Comments

@richard-collette-precisely

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 127.0.6533.122
  • Method of installation: Swashbuckle
  • Swagger-UI version: 5.17.14
  • Swagger/OpenAPI version: 3.0.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: 'Example'
  version: '1'
paths:
  /api/v1/user-profiles:
    post:
      tags:
        - UserProfiles
      summary: Creates a new user profile.
      description: 
      operationId: >-
       CreateUserProfileModel)
      parameters:
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/CreateUserProfileModel
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UserProfileStateDto
components:
  schemas:
    CreateUserProfileModel:
      type: object
      properties:
        firstName:
          maxLength: 50
          pattern: ^[\p{L}\p{M}\p{Zs}\p{N}'-]+$
          type: string
          description: Given name of the user
          nullable: true
    UserProfileStateDto:
      type: object
      properties:
        id:
          type: string
          description: The Okta user id.  Do not use this as a key in applications.
          nullable: true
  securitySchemes:
    Bearer:
      type: http
      description: JWT Bearer Authorization.
      scheme: bearer
      bearerFormat: JWT
tags:
  - name: UserProfiles
    description: Operations for managing user profiles

Describe the bug you're encountering

Given a with a pattern having character categories like \p{N}, Swagger UI is interpreting the braces to mean brace character literal.

The example data that is generated for that property looks like:

  "firstName": "{LsLM{p{sZps-pZ's{}}}}NpN'p'psZ-ssNNMp-'MNL{L'sZp'",

Expected behavior

The delimiters \p{ followed by } should be treated as a character class instead of seeing { as a character literal to match. I should not see braces in the example value produced.

Screenshots

image

Additional context or thoughts

@richard-collette-precisely richard-collette-precisely changed the title Properties with RegEx patterns containing braces renders braces in example values Properties with RegEx patterns containing a unicode property escape renders braces in example values Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant