OAGi / Score

Score
MIT License
9 stars 6 forks source link

Pattern regex is not generating the way it used to #1633

Open dubnemo opened 3 months ago

dubnemo commented 3 months ago

Something changed, and the Pattern regex is not coming in-line as it use to.

Currently, OpenAPI representation:

        telephoneNumber:
          description: "Primary telephone number for the send to party."
          type: "object"
          required:
          - "content"
          additionalProperties: false
          properties:
            content:
              allOf:
              - $ref: "#/components/schemas/type_d87c21021aa047889b2af79495c31deb"
              - example: "404.456.7890"
            typeCode:
              description: "Mobile | Home | Work"
              example: "Mobile"
              type: "string"
              format: "token"

The ref creates an allOf, and an additional C# class in Swagger CodeGen:

    type_d87c21021aa047889b2af79495c31deb:
      type: "string"
      pattern: "^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}$"

Historically, and correct representation:

        telephoneNumber:
          type: "object"
          required:
          - "content"
          additionalProperties: false
          properties:
            content:
              description: "Primary telephone number for the send to party."
              example: "404.456.7890"
              type: "string"
              pattern: "^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}$"
            typeCode:
              description: "Mobile | Home | Work"
              example: "Mobile"
              type: "string"
              format: "token"

This suppresses the allOf and the extra class.

Attachments.

createissueongithubforpatternregex.zip

hakjuoh commented 2 months ago

@dubnemo This issue might relate to the issue https://github.com/OAGi/Score/issues/1104 @kbserm