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

PIMS-402 Add Swagger to Express #1976

Merged
merged 11 commits into from
Dec 18, 2023
Merged

Conversation

dbarkowsky
Copy link
Collaborator

@dbarkowsky dbarkowsky commented Dec 12, 2023

🎯 Summary

PIMS-402

Changes

  • Added swagger packages, including swagger-autogen
  • Included swagger startup in express.ts
  • Added npm run swagger command to generate swagger docs
  • Added swagger.mjs for base swagger configuration
  • Some minor fixes to file names and how constants are set.

See the documentation on swagger-autogen.
swagger-autogen should automatically pick up our routes and list their responses, expected bodies, parameters, etc.
If some of these settings need to be overwritten, they can be specified in comments within the handler/controller. See healthController.ts for an example of manually setting some fields.
image

Testing

  • Run npm run swagger from the express-api folder. It should generate a swagger-output.json file.
    • This is included in the PR, but good to test the generation too.
  • Go to localhost:5000/api/api-docs to see the resulting swagger page.

🔰 Checklist

  • I have read and agree with the following checklist and am following the guidelines in our Code of Conduct document.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where required.
  • I have tested my changes to the best of my ability.
  • My changes generate no new warnings.

Copy link

codeclimate bot commented Dec 12, 2023

Code Climate has analyzed commit aad6465 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 100.0%.

View more on Code Climate.

Copy link
Collaborator

@TaylorFries TaylorFries left a comment

Choose a reason for hiding this comment

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

Swagger docs build and appear as expected!

@dbarkowsky dbarkowsky merged commit 17ed4cb into main Dec 18, 2023
3 checks passed
@dbarkowsky dbarkowsky deleted the PIMS-402-Add-Swagger-to-Express branch December 18, 2023 16:52
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.

2 participants