Skip to content

Simplify Swagger authentication field headers to "User Login" #1064

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 11, 2025

Problem

The Swagger UI authentication section displayed a technical and user-unfriendly header text "OAuth2PasswordOrClientCredentialsBearer (OAuth2, password)" which was confusing for end users trying to authenticate with the API.

Current authentication dialog showing technical OAuth2 text

Solution

Added JavaScript code to the existing Swagger UI customization that:

  1. Listens for the nmdcInit event (as suggested in the issue)
  2. Searches for DOM elements containing the technical OAuth2 authentication text
  3. Replaces both "OAuth2PasswordOrClientCredentialsBearer (OAuth2, password)" and "OAuth2PasswordOrClientCredentialsBearer" with the user-friendly "User Login" text
  4. Uses a 500ms timeout to ensure Swagger UI has fully rendered before making changes

Implementation Details

The change is minimal and surgical - only 15 lines of JavaScript added to /nmdc_runtime/api/swagger_ui/assets/script.js. The modification:

  • Preserves all existing functionality
  • Only changes the display text, not the underlying authentication mechanism
  • Uses the existing nmdcInit event infrastructure already in place
  • Applies the change client-side without affecting server-side authentication logic

Testing

Created and tested a standalone HTML page that simulates the authentication section behavior. The test confirms that the text replacement works correctly for both the full technical text and shortened versions.

Test showing "User Login" text replacement

This change significantly improves the usability of the Swagger UI by making the authentication section more accessible and less intimidating for end users.

Fixes #895.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Usability: Simplify Swagger authentication field headers Simplify Swagger authentication field headers to "User Login" Jul 11, 2025
@Copilot Copilot AI requested a review from shreddd July 11, 2025 19:36
Copilot finished work on behalf of shreddd July 11, 2025 19:36
@shreddd shreddd requested a review from eecavanna July 11, 2025 19:43
@shreddd
Copy link
Collaborator

shreddd commented Jul 14, 2025

@eecavanna - lmk if this solution looks ok to you.

@eecavanna
Copy link
Collaborator

Thanks, @shreddd. At first glance, I am nervous about the fact that Copilot has introduced a setTimeout to wait for DOM elements to load. I'll review this later today and edit/approve/merge.

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.

Usability: Simplify Swagger authentication field headers
3 participants