open-traffic-generator / openapiart

OpenAPI artifact generator
MIT License
6 stars 4 forks source link

adding support for signed integers in x-field-pattern #456

Closed Vibaswan closed 8 months ago

Vibaswan commented 9 months ago

Adding a new property in x-field-pattern

signed:
  description: >-
    Valid only if the format is of type integer.
    Indicates whether the integer value is signed or unsigned.
    If the property is not specified the value is considered as unsigned.
    Its a boolean value which is optional in nature.
  type: boolean

Example model snippet (Users snippet)

SignedIntegerPattern:
  description: Test signed integer pattern
  type: object
  properties:
    integer:
      x-field-pattern:
        format: integer
        default: 0
        signed: true
        length: 8
        features: [count]
      x-field-uid: 1

Final output in yaml after bundling

Pattern.SignedIntegerPattern.Integer:
      description: |-
        TBD
      type: object
      properties:
        choice:
          type: string
          x-enum:
            value:
              x-field-uid: 2
            values:
              x-field-uid: 3
            increment:
              x-field-uid: 4
            decrement:
              x-field-uid: 5
          default: value
          x-field-uid: 1
          enum:
          - value
          - values
          - increment
          - decrement
        value:
          type: integer
          x-field-uid: 2
          default: 0
          format: int32
          minimum: -256
          maximum: 255
        values:
          type: array
          items:
            type: integer
            format: int32
            minimum: -256
            maximum: 255
          x-field-uid: 3
          default:
          - 0
        increment:
          $ref: '#/components/schemas/Pattern.SignedIntegerPattern.Integer.Counter'
          x-field-uid: 5
        decrement:
          $ref: '#/components/schemas/Pattern.SignedIntegerPattern.Integer.Counter'
          x-field-uid: 6