some enums missing from OpenAPI schema #8225

Closed
opened 2025-12-29 20:34:01 +01:00 by adam · 1 comment
Owner

Originally created by @CADbloke on GitHub (Jun 22, 2023).

Originally assigned to: @abhi1693 on GitHub.

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

Originally created by @CADbloke on GitHub (Jun 22, 2023). Originally assigned to: @abhi1693 on GitHub. ### 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: ````yaml 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) ````yaml status: enum: - connected - planned - decommissioning type: string description: |- * `connected` - Connected * `planned` - Planned * `decommissioning` - Decommissioning ```` ### v3.1.6 Cable: ````yaml 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
adam added the type: bugstatus: acceptedseverity: lowtopic: OpenAPI labels 2025-12-29 20:34:01 +01:00
adam closed this issue 2025-12-29 20:34:01 +01:00
Author
Owner

@CADbloke commented on GitHub (Jun 26, 2023):

Thanks for the quick fix. :)

@CADbloke commented on GitHub (Jun 26, 2023): Thanks for the quick fix. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8225