-
Notifications
You must be signed in to change notification settings - Fork 0
Add message to Swagger UI page encouraging visitors to use Runtime API instead #1715
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a message to the Swagger UI page encouraging visitors to use the Runtime API instead of the current API, which was designed specifically for NMDC portals. The changes convert the API description from hardcoded HTML to a templated Markdown format and provide clearer guidance for different user types.
- Converted HTML description to Markdown format with template-based content loading
- Added messaging directing general users to the Runtime API while preserving developer instructions
- Implemented a template system with placeholder replacement for better maintainability
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
nmdc_server/swagger_ui/templates/description.template.md | New template file containing the Markdown description with placeholders for URLs |
nmdc_server/swagger_ui/helpers.py | New helper module with template loading functionality using importlib.resources |
nmdc_server/app.py | Updated to use template-based description with placeholder replacement instead of hardcoded HTML |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Note to Reviewers: The content of the message will change (based upon feedback I received during today's infrastructure meeting, and—I expect—some follow-on discussions on Slack). I would still like for |
A team member in attendance at today's infrastructure meeting expressed concern that the messaging we use might (incorrectly) imply that anyone can access anyone else's submission portal submissions. |
description = ( | ||
load_template("description.template.md") | ||
.replace("{{ developer_tools_url }}", "/user") | ||
.replace("{{ runtime_api_url }}", "https://api.microbiomedata.org") | ||
.replace("{{ nmdc_data_portal_url }}", "https://data.microbiomedata.org") | ||
.replace( | ||
"{{ nmdc_submission_portal_url }}", "https://data.microbiomedata.org/submission/home" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these URLs be set as configuration? That way the dev swagger page can link to the dev data portal, etc?
On this branch, I made the following changes:
FastAPI
constructor says that itsdescription
parameter can be a Markdown string (and I did not see anything about it being able to be an HTML string; indeed, I confirmed arbitrary HTML code—such as<style>
tags with corresponding CSS classes applied to HTML elements—within the description did not seem to take effect). Note that the previous description string, even with its<a>
tag, may have been "sufficiently Markdown-y" already.app.py
. The template file uses a custom{{ name }}
syntax for placeholders, andapp.py
takes care of replacing those placeholders with their final values. I can see this being useful for future iterations of the description. In case reviewers don't feel comfortable with this additional complexity, I'd be OK removing it and hard-coding the URLs in the description for now. The placeholder syntax (and the helper function used to read the template into a string) were copied from the refscan repo.Screenshots
Here's what the description looks like on this branch:
In contrast, here's what it looks like on
main
today:Issues
Fixes #1593
Fixes microbiomedata/nmdc-runtime#1056