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

fix(api): Fix openapi documentation display script #805

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

ndv99
Copy link
Collaborator

@ndv99 ndv99 commented Sep 4, 2023

Done

  • Fixed OpenAPI display script by replacing "application/json" check in request body with "multipart/form-data"

QA

  • Go to /docs/api
  • Open a few endpoints that have methods with request bodies
  • Ensure there are no duplicate parameters and that the properties are being displayed correctly

A few to check:

  • PUT /MAAS/api/2.0/boot-sources/{boot_source_id}/selections/{id}
  • DELETE /MAAS/api/2.0/devices/{system_id}/
  • DELETE /MAAS/api/2.0/devices/{system_id}/
  • PUT /MAAS/api/2.0/dnsresourcerecords/{id}/

Screenshots

Before

image

After

image

@webteam-app
Copy link

Demo starting at https://maas-io-805.demos.haus

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Merging #805 (a7132ff) into main (561e284) will increase coverage by 2.93%.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head a7132ff differs from pull request most recent head c5c7339. Consider uploading reports for the commit c5c7339 to get more accurate results

@@            Coverage Diff             @@
##             main     #805      +/-   ##
==========================================
+ Coverage   61.65%   64.59%   +2.93%     
==========================================
  Files           8        8              
  Lines         193      209      +16     
==========================================
+ Hits          119      135      +16     
  Misses         74       74              
Flag Coverage Δ
python 64.59% <100.00%> (+2.93%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
tests/test_routes.py 95.45% <100.00%> (+3.78%) ⬆️
webapp/app.py 86.79% <100.00%> (+1.68%) ⬆️

Copy link

@tmerten tmerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if the if clause can be more explicit and whether we might still need parameter descriptions in case there is no multipart/form-data in the requestBody.

{%endif%}
{%for property in item[endpoint][method]["requestBody"]["content"]["application/json"]["schema"]["properties"]%}
<p><md-block><code>{{property}}</code> (<em>{{item[endpoint][method]["requestBody"]["content"]["application/json"]["schema"]["properties"][property]["type"]}}</em>): {%if property in item[endpoint][method]["requestBody"]["content"]["application/json"]["schema"]["required"]%}Required{%else%}Optional{%endif%}. {{item[endpoint][method]["requestBody"]["content"]["application/json"]["schema"]["properties"][property]["description"].replace(" -", "\n -")}}</md-block></p>
<p><strong>Request body (multipart/form-data)</strong></p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is true for all request_bodys or only the ones with files. Or to put it differently, can we check for item[endpoint][method]["requestBody"]["content"]["multipart/form-data"] directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can check for this, but currently I am sure that this is true for all request bodies - trying this with "application/json" results in errors, but having run this locally with the most recent schema, there are no errors when using "multipart/form-data". I've checked through the schema to verify this as well.

Copy link

@tmerten tmerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for checking!

Copy link
Contributor

@petermakowski petermakowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndv99 ndv99 merged commit b526e19 into canonical:main Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants