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

some enums missing from OpenAPI schema #12960

Closed
CADbloke opened this issue Jun 22, 2023 · 1 comment · Fixed by #12986
Closed

some enums missing from OpenAPI schema #12960

CADbloke opened this issue Jun 22, 2023 · 1 comment · Fixed by #12986
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application

Comments

@CADbloke
Copy link

NetBox version

v3.5.4

Python version

3.8

Steps to Reproduce

  1. https://demo.netbox.dev/api/schema/ - this is where v3.5.4 schema is from
  2. observe that some enums are missing from GET objects
  3. those enums are in the Writable*Request objects
  4. while the schema is correct that a string is returned but that's what JSON is
  5. The Model classes generated from the schema don't validate the response and they are the wrong type of property.
  6. example: Cable.Status - note Type is ok (actually improved with Display descriptions), Status is not ok.
    blank lines added so you can find it....

v3.5.4 Cable:

    Cable:
      type: object
      description: Adds support for custom fields and tags.
      properties:
        id:
          type: integer
          readOnly: true
        url:
          type: string
          format: uri
          readOnly: true
        display:
          type: string
          readOnly: true
        type:
          enum:
          - cat3
          - cat5
          - cat5e
          - cat6
          - cat6a
          - cat7
          - cat7a
          - cat8
          - dac-active
          - dac-passive
          - mrj21-trunk
          - coaxial
          - mmf
          - mmf-om1
          - mmf-om2
          - mmf-om3
          - mmf-om4
          - mmf-om5
          - smf
          - smf-os1
          - smf-os2
          - aoc
          - power
          - ''
          type: string
          description: |-
            * `cat3` - CAT3
            * `cat5` - CAT5
            * `cat5e` - CAT5e
            * `cat6` - CAT6
            * `cat6a` - CAT6a
            * `cat7` - CAT7
            * `cat7a` - CAT7a
            * `cat8` - CAT8
            * `dac-active` - Direct Attach Copper (Active)
            * `dac-passive` - Direct Attach Copper (Passive)
            * `mrj21-trunk` - MRJ21 Trunk
            * `coaxial` - Coaxial
            * `mmf` - Multimode Fiber
            * `mmf-om1` - Multimode Fiber (OM1)
            * `mmf-om2` - Multimode Fiber (OM2)
            * `mmf-om3` - Multimode Fiber (OM3)
            * `mmf-om4` - Multimode Fiber (OM4)
            * `mmf-om5` - Multimode Fiber (OM5)
            * `smf` - Singlemode Fiber
            * `smf-os1` - Singlemode Fiber (OS1)
            * `smf-os2` - Singlemode Fiber (OS2)
            * `aoc` - Active Optical Cabling (AOC)
            * `power` - Power
        a_terminations:
          type: array
          items:
            $ref: '#/components/schemas/GenericObject'
        b_terminations:
          type: array
          items:
            $ref: '#/components/schemas/GenericObject'


        status:
          type: object
          properties:
            value:
              type: string
            label:
              type: string


        tenant:
          allOf:
          - $ref: '#/components/schemas/NestedTenant'
          nullable: true
        label:
          type: string
          maxLength: 100
        color:
          type: string
          pattern: ^[0-9a-f]{6}$
          maxLength: 6
        length:
          type: number
          format: double
          maximum: 1000000
          minimum: -1000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          nullable: true
        length_unit:
          type: object
          properties:
            value:
              type: string
            label:
              type: string
          nullable: true
        description:
          type: string
          maxLength: 200
        comments:
          type: string
        tags:
          type: array
          items:
            $ref: '#/components/schemas/NestedTag'
        custom_fields:
          type: object
          additionalProperties: {}
        created:
          type: string
          format: date-time
          readOnly: true
          nullable: true
        last_updated:
          type: string
          format: date-time
          readOnly: true
          nullable: true
      required:
      - created
      - display
      - id
      - last_updated
      - url

v3.5.4 WritableCableRequest:

(partial)

        status:
          enum:
          - connected
          - planned
          - decommissioning
          type: string
          description: |-
            * `connected` - Connected
            * `planned` - Planned
            * `decommissioning` - Decommissioning

v3.1.6 Cable:

  Cable:
    required:
      - termination_a_type
      - termination_a_id
      - termination_b_type
      - termination_b_id
    type: object
    properties:
      id:
        title: Id
        type: integer
        readOnly: true
      url:
        title: Url
        type: string
        format: uri
        readOnly: true
      display:
        title: Display
        type: string
        readOnly: true
      termination_a_type:
        title: Termination a type
        type: string
      termination_a_id:
        title: Termination a id
        type: integer
        maximum: 2147483647
        minimum: 0
      termination_a:
        title: Termination a
        type: object
        additionalProperties:
          type: string
          x-nullable: true
        readOnly: true
      termination_b_type:
        title: Termination b type
        type: string
      termination_b_id:
        title: Termination b id
        type: integer
        maximum: 2147483647
        minimum: 0
      termination_b:
        title: Termination b
        type: object
        additionalProperties:
          type: string
          x-nullable: true
        readOnly: true
      type:
        title: Type
        type: string
        enum:
          - cat3
          - cat5
          - cat5e
          - cat6
          - cat6a
          - cat7
          - cat7a
          - cat8
          - dac-active
          - dac-passive
          - mrj21-trunk
          - coaxial
          - mmf
          - mmf-om1
          - mmf-om2
          - mmf-om3
          - mmf-om4
          - mmf-om5
          - smf
          - smf-os1
          - smf-os2
          - aoc
          - power


      status:
        title: Status
        required:
          - label
          - value
        type: object
        properties:
          label:
            type: string
            enum:
              - Connected
              - Planned
              - Decommissioning
          value:
            type: string
            enum:
              - connected
              - planned
              - decommissioning

Expected Behavior

Expected: proper types in the GET / Read objects

Observed Behavior

Observed: wrong types in the GET / Read objects

@CADbloke CADbloke added the type: bug A confirmed report of unexpected behavior in the application label Jun 22, 2023
@jeremystretch jeremystretch added topic: OpenAPI status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Jun 22, 2023
@abhi1693 abhi1693 self-assigned this Jun 23, 2023
@abhi1693 abhi1693 added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jun 23, 2023
@CADbloke
Copy link
Author

Thanks for the quick fix. :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants