Skip to content

Fix Swagger API server URL - #9

Merged
ccjngwn merged 1 commit into
developfrom
codex/fix-swagger-server-url
Jul 10, 2026
Merged

Fix Swagger API server URL#9
ccjngwn merged 1 commit into
developfrom
codex/fix-swagger-server-url

Conversation

@ccjngwn

@ccjngwn ccjngwn commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add an explicit Swagger/OpenAPI server URL so Swagger UI sends requests to a valid http:// or https:// API origin.
  • Configure local, prod, and test defaults for app.swagger.server-url.
  • Enable forwarded header handling in prod so proxied HTTPS requests are interpreted correctly.

Root cause

Updating CORS_ALLOWED_ORIGINS alone does not change the request URL generated by Swagger UI. When Swagger resolves an invalid or scheme-less API server URL, the browser reports Failed to fetch with URL scheme must be "http" or "https" for CORS request.

Validation

  • ./gradlew test

Summary by CodeRabbit

  • New Features

    • API documentation now displays a configured server URL, with support for environment-specific settings.
    • Production deployments can correctly account for forwarded request headers.
  • Bug Fixes

    • Added validation to ensure configured documentation server URLs use supported HTTP or HTTPS schemes.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b40a0b11-9efa-4987-a295-5e571fece92a

📥 Commits

Reviewing files that changed from the base of the PR and between dd0ea36 and 971e07e.

📒 Files selected for processing (5)
  • .env.example
  • src/main/java/com/cotato/cokerthon/global/config/SwaggerConfig.java
  • src/main/resources/application-prod.yml
  • src/main/resources/application.yml
  • src/test/resources/application.yml

📝 Walkthrough

Walkthrough

Swagger server URLs are now configurable through environment-specific properties, injected into SwaggerConfig, validated for HTTP(S) schemes, and conditionally added to the generated OpenAPI document. Production also enables framework forwarded-header handling.

Changes

Swagger server URL configuration

Layer / File(s) Summary
Environment-specific Swagger configuration
src/main/resources/application.yml, src/main/resources/application-prod.yml, src/test/resources/application.yml, .env.example
Defines local, production, test, and example environment values for app.swagger.server-url; production also sets server.forward-headers-strategy to framework.
Validated OpenAPI server registration
src/main/java/com/cotato/cokerthon/global/config/SwaggerConfig.java
Injects the configured URL, validates that its scheme is http or https, and conditionally adds it to the OpenAPI servers list.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ApplicationConfig
  participant SwaggerConfig
  participant OpenAPI
  ApplicationConfig->>SwaggerConfig: inject app.swagger.server-url
  SwaggerConfig->>SwaggerConfig: validate http or https scheme
  SwaggerConfig->>OpenAPI: add validated server URL
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-swagger-server-url

Comment @coderabbitai help to get the list of available commands.

@ccjngwn
ccjngwn marked this pull request as ready for review July 10, 2026 18:37
@ccjngwn
ccjngwn merged commit 043e55b into develop Jul 10, 2026
4 checks passed
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.

1 participant