Skip to content

Conversation

@mraerino
Copy link
Contributor

Fixes: #17488

The OpenAPI schema for vid_ranges cannot automatically be discovered by drf-spectacular since it's a custom serializer with no fields. Therefore we need to manually provide the OpenAPI schema for the type we expect to see in requests and responses.

On top of that there is a bug in drf-spectacular that required the workaround with the custom list class (tfranzel/drf-spectacular#1353).

@mraerino mraerino changed the title Fix OpenAPI schema for vid_ranges in VLANGroup so it shows up Fix OpenAPI schema for vid_ranges in VLANGroup so it shows up Dec 13, 2024
@mraerino mraerino changed the title Fix OpenAPI schema for vid_ranges in VLANGroup so it shows up Fix definition of vid_ranges in VLANGroup so it shows up in the OpenAPI schema Dec 13, 2024
@mraerino mraerino marked this pull request as ready for review December 13, 2024 21:25
@jeremystretch
Copy link
Member

@mraerino did you see the comment here regarding the use of extend_schema_field() on a serializer (versus a field)? I suspect a more prudent solution might be to rewrite IntegerRangeSerializer to use IntegerField, though I'm not sure of the specifics.

@mraerino
Copy link
Contributor Author

yeah i saw. i think this is likely a little bit more complex and i wanted to get this bug fix out quickly so people can use the API again.

I can look into improving this in another PR, if you're ok with that?

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Jan 29, 2025
@mraerino
Copy link
Contributor Author

mraerino commented Feb 2, 2025

@jeremystretch i changed the implementation to use a schema extension instead of an annotation, as recommended by the spectacular devs.

I don't think using IntegerField will work since we have an array of integers in an array and 2 dimensions cannot be modelled without a custom serializer

@arthanson arthanson removed the pending closure Requires immediate attention to avoid being closed for inactivity label Feb 18, 2025
@arthanson
Copy link
Collaborator

@mraerino Can you please rebase this to main

@mraerino mraerino force-pushed the feat/api-expose-vid-ranges branch from 4d794da to bd8be38 Compare February 18, 2025 18:54
@mraerino
Copy link
Contributor Author

@mraerino Can you please rebase this to main

done!

@mraerino mraerino changed the base branch from develop to main February 18, 2025 18:55
@arthanson arthanson self-requested a review February 26, 2025 00:05
@arthanson arthanson merged commit c81f4da into netbox-community:main Feb 26, 2025
3 checks passed
@mraerino mraerino deleted the feat/api-expose-vid-ranges branch March 3, 2025 09:28
bctiemann pushed a commit that referenced this pull request Mar 6, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New field vid_ranges on vlan-group missing in API

3 participants