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

Choice field is not serialized as string #12151

Closed
amhn opened this issue Apr 2, 2023 · 0 comments
Closed

Choice field is not serialized as string #12151

amhn opened this issue Apr 2, 2023 · 0 comments
Assignees
Labels
beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@amhn
Copy link
Contributor

amhn commented Apr 2, 2023

NetBox version

v3.5-beta

Python version

3.10

Steps to Reproduce

Create Aggregate. Go to API and List Aggregates

Expected Behavior

The family field is a string as specified in openapi spec. Or openapi-spec is changed to specify this field as an object in the response.

Observed Behavior

The family field actually is an object:

      "family": {
        "value": 4,
        "label": "IPv4"
      },

This violates the definition.

Removing @extend_schema_field(OpenApiTypes.STR) from class ChoiceField produces in this case a more correct API definition:

                    "family": {
                        "type": "object",
                        "properties": {
                            "value": {
                                "type": "string"
                            },
                            "label": {
                                "type": "string"
                            }
                        },
                        "readOnly": true
                    },

instead of

                    "family": {
                        "type": "string",
                        "readOnly": true
                    },
@amhn amhn added the type: bug A confirmed report of unexpected behavior in the application label Apr 2, 2023
@kkthxbye-code kkthxbye-code added the beta Concerns a bug/feature in a beta release label Apr 2, 2023
@arthanson arthanson self-assigned this Apr 3, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

4 participants