Skip to content

Conversation

eecavanna
Copy link
Collaborator

@eecavanna eecavanna commented Jul 31, 2025

On this branch, I made the following changes:

  1. Converted the HTML description string into a Markdown description string. The docstring of the FastAPI constructor says that its description 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.
  2. Refactored the description code so that the description is loaded from a template file, rather than being written in app.py. The template file uses a custom {{ name }} syntax for placeholders, and app.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.
  3. Added a message to the description, which says that this API was designed to be accessed only by specific NMDC programs, and which suggests that the visitor use the Runtime API instead. This was my primary goal with this PR. The user research team recently received feedback from Runtime users saying that they came across this "other" API and didn't understand what it was / wasn't.

Screenshots

Here's what the description looks like on this branch:

image

In contrast, here's what it looks like on main today:

image

Issues

Fixes #1593

Fixes microbiomedata/nmdc-runtime#1056

Copy link
Contributor

@Copilot Copilot AI left a 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>
@eecavanna
Copy link
Collaborator Author

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 nmdc-server maintainers to review the code changes. I will unassign the Runtime squad members as reviewers, since the content is still under development.

@eecavanna
Copy link
Collaborator Author

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.

Comment on lines +46 to +52
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"
Copy link
Collaborator

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?

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.

Clarify role of Data Portal API versus Runtime API to users Add message to Data Portal Swagger UI encouraging visitors to use Runtime API instead
2 participants