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

Swagger UI Doesn't Report Status as a Required Field Correctly #313

Closed
nniehoff opened this issue Apr 13, 2021 · 3 comments · Fixed by #1216
Closed

Swagger UI Doesn't Report Status as a Required Field Correctly #313

nniehoff opened this issue Apr 13, 2021 · 3 comments · Fixed by #1216
Labels
type: bug Something isn't working as expected type: documentation Improvements or additions to documentation

Comments

@nniehoff
Copy link
Contributor

Not sure if this is global or specific to power-feeds status but I also checked devices and status is not required there either in swagger.

Environment

  • Python version: 3.6
  • Nautobot version: 1.0b3

Steps to Reproduce

  1. Go to the swagger UI
  2. Look for POST POST ​/dcim​/power-feeds​/
  3. Look under parameters in the model view, status is shown as not required

Expected Behavior

Status should have a required * as it is a required field.

Observed Behavior

Swagger shows it as not required

@jathanism
Copy link
Contributor

jathanism commented Apr 13, 2021

Thanks @nniehoff for reporting this. Interestingly it's marked as non-required field in the serializer mixin, but obviously that's now how it is behaving:

https://github.com/nautobot/nautobot/blob/develop/nautobot/extras/api/serializers.py#L873-L876

@glennmatthews glennmatthews added type: bug Something isn't working as expected type: documentation Improvements or additions to documentation labels Apr 14, 2021
@jathanism
Copy link
Contributor

It's because of model validation. The field not being required is overridden by the fact that the field is required when the model is validated.

@jathanism jathanism added this to the v1.1.0 milestone Apr 21, 2021
@jedelman8 jedelman8 added this to To do in Release v1.1.0 via automation Apr 29, 2021
@jedelman8 jedelman8 removed this from the v1.1.0 milestone May 28, 2021
@jedelman8 jedelman8 removed this from To do in Release v1.1.0 May 28, 2021
@jedelman8 jedelman8 modified the milestone: v1.2.0 Jul 26, 2021
@glennmatthews
Copy link
Contributor

Updating the link: https://github.com/nautobot/nautobot/blob/develop/nautobot/extras/api/serializers.py#L873 (StatusModelSerializerMixin). It probably should be required=True - maybe just change this and test to see what breaks?

@glennmatthews glennmatthews changed the title Swagger UI Doesn't Report Required Fields Correctly Swagger UI Doesn't Report Status as a Required Field Correctly Dec 21, 2021
glennmatthews added a commit that referenced this issue Jan 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected type: documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants