Add Swagger/OpenAPI 3.0 docs and interactive Swagger UI for Thomas REST API#1055
Draft
Copilot wants to merge 2 commits into
Draft
Add Swagger/OpenAPI 3.0 docs and interactive Swagger UI for Thomas REST API#1055Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
Agent-Logs-Url: https://github.com/iheartradio/thomas/sessions/b4469701-2c39-40d7-8b2e-9ffb532ed249 Co-authored-by: lofoyet <43834836+lofoyet@users.noreply.github.com>
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
🛡️ The following IaC misconfigurations have been detected
| NAME | FILE | ||
|---|---|---|---|
| Global Server Object Uses HTTP | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response Code Missing (v3) | ...swagger/openapi.yaml | View in code | |
| Response on operations that should have a body has undefined schema | ...swagger/openapi.yaml | View in code | |
| Response on operations that should have a body has undefined schema | ...swagger/openapi.yaml | View in code | |
| Empty Array | ...swagger/openapi.yaml | View in code | |
| Empty Array | ...swagger/openapi.yaml | View in code | |
| Empty Array | ...swagger/openapi.yaml | View in code | |
| Empty Array | ...swagger/openapi.yaml | View in code | |
| Path Is Ambiguous | ...swagger/openapi.yaml | View in code | |
| Path Is Ambiguous | ...swagger/openapi.yaml | View in code | |
| ... | ... | ... | ... |
Copilot
AI
changed the title
[WIP] Add Swagger/OpenAPI 3.0 documentation for Thomas A/B testing API
Add Swagger/OpenAPI 3.0 docs and interactive Swagger UI for Thomas REST API
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thomas has no machine-readable API contract or interactive docs for its HTTP layer. This adds a static OpenAPI 3.0 spec and a CDN-backed Swagger UI served directly from the existing http4s server—no tapir or rho required.
Changes
http4s/src/main/resources/swagger/openapi.yaml— Full OpenAPI 3.0 spec covering all public endpoints (/users/groups/query,/health,/tests/*,/features/*) and internal management endpoints (/internal/testsCRUD), with complete schema definitions forUserGroupQuery,AbtestSpec,UserGroupQueryResult,EntityAbtest,Group, etc.http4s/src/main/scala/com/iheart/thomas/http4s/SwaggerUIRoutes.scala— NewHttpRoutesserving two endpoints:GET /swagger/openapi.yaml— spec loaded from classpath, served astext/yamlGET /swagger-ui— Swagger UI HTML loading assets from unpkg CDN, pinned to v5.17.14 with SRIintegrityhashes on both<link>and<script>tags; includes a null-guard on the classpath resource loadhttp4s/src/main/scala/com/iheart/thomas/http4s/AdminUI.scala— PrependsSwaggerUIRoutesto the top-level route composition; requires only the existingMonadThrow[F]bound already onAdminUI.README.md— Documents access URLs (/swagger-ui,/swagger/openapi.yaml).Route wiring
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
repo.scala-sbt.org/usr/bin/java java -Dfile.encoding=UTF8 -Xms1G -Xmx6G -XX:MaxMetaspaceSize=2G -XX:ReservedCodeCacheSize=250M -XX:+TieredCompilation -XX:-UseGCOverheadLimit -Dsbt.script=/tmp/sbt/bin/sbt -Dscala.ext.dirs=/home/REDACTED/.sbt/1.0/java9-rt-ext-eclipse_adoptium_17_0_18 -jar /tmp/sbt/bin/sbt-launch.jar http4s/compile(dns block)repo.typesafe.com/usr/bin/java java -Dfile.encoding=UTF8 -Xms1G -Xmx6G -XX:MaxMetaspaceSize=2G -XX:ReservedCodeCacheSize=250M -XX:+TieredCompilation -XX:-UseGCOverheadLimit -Dsbt.script=/tmp/sbt/bin/sbt -Dscala.ext.dirs=/home/REDACTED/.sbt/1.0/java9-rt-ext-eclipse_adoptium_17_0_18 -jar /tmp/sbt/bin/sbt-launch.jar http4s/compile(dns block)unpkg.com/usr/bin/curl curl -sI REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Overview
Add Swagger/OpenAPI 3.0 documentation for the Thomas A/B testing REST API. The project uses http4s for its HTTP layer (see
http4s/module). The goal is to produce interactive Swagger UI docs and a machine-readableopenapi.yaml/openapi.jsonspec that describes all public and internal HTTP endpoints.Approach
Use tapir with the http4s integration (
tapir-http4s-server) and the OpenAPI docs integration (tapir-openapi-docs,tapir-swagger-ui-bundle) to describe existing endpoints and serve Swagger UI.Alternatively, if tapir is too invasive, use
rhoor simply write a staticopenapi.yamlfile and serve it alongside the Swagger UI static assets. A static OpenAPI YAML approach is the least-invasive option.Endpoints to Document
The following REST endpoints are defined in the codebase:
Public Endpoints (
AbtestService)POST/users/groups/queryUserGroupQueryGET/health{"status":"healthy","version":"..."}GET/tests/history/{at}atGET/tests/{endAfter}endAfterGET/testsat(epoch ms) andendAfterquery paramsGET/testsWithFeaturesatquery paramGET/testsDataatEpochMilli,durationMillisecond)GET/tests/{testId}GET/tests/cacheatquery paramGET/featuresGET/features/{feature}/testsGET/features/{feature}/overridesInternal / Management Endpoints (
AbtestManagementService, auth-protected)POST/internal/testsAbtestSpec), optional?auto=truePOST/internal/tests/autoauto=truePUT/internal/testsAbtestSpec)DELETE/internal/tests/{testId}Key Data Models
All models live in
core/src/main/scala/com/iheart/thomas/abtest/model/package.scala.UserGroupQuery(POST body for/users/groups/query){ "userId": "string | null", "at": "ISO-8601 datetime | null", "tags": ["string"], "meta": { "key": "value" }, "features": ["featureName"], "eligibilityControlFilter": "All | On | Off" }AbtestSpec(POST/PUT body for test creation){ "name": "string", "feature": "string", "author": "string", "start": "ISO-8601 datetime", "end": "ISO-8601 datetime | null", "groups": [ { "name": "string", "size": 0.5, "meta": {}, "description": "string | null" } ], "requiredTags": ["string"], "alternativeIdName": "string | null", "userMetaCriteria": "object | null", "reshuffle": false, "segmentRanges": [{ "start": 0.0, "end": 1.0 }], "specialization": "MultiArmBandit | null", "note": "string | null" }UserGroupQueryResult(response){ "at": "epoch millis", "groups": { "featureName": "groupName" }, "meta": {} }Entity[Abtest](response){ "_id": "string", "data": { /* Abtest fields same as AbtestSpec but with ranges and salt */ } }Implementation Tasks
Add a static
openapi.yamlfile tohttp4s/src/main/resources/swagger/openapi.yaml(or at the project root asdocs/openapi.yaml) documenting all endpoints above with request/response schemas.Serve Swagger UI — Add a new
SwaggerUIRouteshttp4s service inhttp4s/src/main/scala/com/iheart/thomas/http4s/SwaggerUIRoutes.scalathat:openapi.yamlatGET /swagger/openapi.yamlGET /swagger-uiusing swagger-ui webjars or inline HTML pointing to a CDN.Wire up the new routes into
AdminUI.scalaso Swagger UI is accessible when running the server.Add
swagger-uiwebjar dependency tobuild.sbt(orproject/Dependencies.scala):Update
README.mdwith a note on how to access the Swagger UI (e.g.,http://localhost:8080/swagger-ui).File locations in the repo
http4s/src/main/scala/com/iheart/thomas/http4s/abtest/AbtestService.scalahttp4s/src/main/scala/com/iheart/thomas/http4s/abtest/AbtestManagementService.scalaThis pull request was created from Copilot chat.