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

Add OpenAPI (Swagger) documentation for Fides Privacy Center API endpoints (/fides.js) #3341

Merged
merged 5 commits into from
May 24, 2023

Conversation

NevilleS
Copy link
Contributor

@NevilleS NevilleS commented May 21, 2023

Closes #3275

Code Changes

  • Add next-swagger-doc and swagger-react-ui modules for the OpenAPI docs
  • Add OpenAPI doc for /fides.js route using special @swagger JSdoc syntax
  • Add a /docs page to show the API docs, but only in development mode
  • Add lint rule to ensure that future API routes have docs

Steps to Confirm

  • Run cd clients/privacy-center && npm install && turbo dev
  • Open http://localhost:3000/docs
  • Run nox -s "fides_env(test)" and confirm that the API documentation is not there (should only be dev builds)

image
image

Pre-Merge Checklist

Description Of Changes

This adds some in-app documentation for how to use the /fides.js route to generate the Fides.js bundle.

@NevilleS
Copy link
Contributor Author

Great, now I'm getting a mysterious build error in CI...

#15 43.02 npm ERR! code 1
#15 43.02 npm ERR! path /fides/clients/node_modules/turbo
#15 43.02 npm ERR! command failed
#15 43.02 npm ERR! command sh -c -- node install.js
#15 43.02 npm ERR! [turbo] Failed to find package "turbo-linux-arm64" on the file system
#15 43.02 npm ERR! 
#15 43.02 npm ERR! This can happen if you use the "--no-optional" flag. The "optionalDependencies"
#15 43.02 npm ERR! package.json feature is used by turbo to install the correct binary executable
#15 43.02 npm ERR! for your current platform. This install script will now attempt to work around
#15 43.02 npm ERR! this. If that fails, you need to remove the "--no-optional" flag to use turbo.

Seems to be an open issue affecting folks like us developing on Macs and running CI in Linux:

@cypress
Copy link

cypress bot commented May 21, 2023

Passing run #2146 ↗︎

0 4 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge db2f298 into 3594d16...
Project: fides Commit: ebb4715624 ℹ️
Status: Passed Duration: 00:44 💡
Started: May 24, 2023 2:56 PM Ended: May 24, 2023 2:57 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@NevilleS
Copy link
Contributor Author

Seems like an unrelated test failure for admin-ui custom fields code:

  1) System management with Plus features
       custom metadata
         can populate initial custom metadata:

      AssertionError: expected 'id-custom-field-starter-pokemon' to deeply equal 'id-custom-field-pokemon-party'
      + expected - actual

      -'id-custom-field-starter-pokemon'
      +'id-custom-field-pokemon-party'

This is failing on main too.

return { props: {} };
};

const Docs: NextPage = () => <SwaggerUI url="/api/openapi.json" />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this page to the README.md of privacy center?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion, I'll do that! I already wrote some nice words in the PR description I can copypasta

@NevilleS NevilleS merged commit 1014fb4 into main May 24, 2023
@NevilleS NevilleS deleted the ns-add-privacy-center-swagger-docs branch May 24, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add developer documentation for how to use the Privacy Center's /fides.js API
2 participants