Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ browse <http://localhost:18080/docs> (RA) and
scripts/demo/start.sh`. The raw OpenAPI bytes live at
`/docs/openapi.yaml` on each host.

The RA and TL specs use relative server URLs so Swagger requests target the
host serving the document: `/v2` for RA management, and `/` for the RA events
feed and TL. Generated clients must be configured with an absolute deployment
base URL, preserving those path prefixes; the specs provide no default host.

To call protected endpoints from Swagger UI's "Try it out" button:
click **Authorize** in the top-right and paste the static API key.
The quickstart defaults are:
Expand Down
15 changes: 9 additions & 6 deletions internal/adapter/docsui/docsui.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func Mount(r chi.Router, spec Spec) {
// by itself — we pass it only the OpenAPI URL and a few cosmetic
// options. dom_id anchors the app into the page body.
func renderSwaggerUI(title string) string {
// Pin the Swagger UI version so upstream changes can't break
// local dev overnight. 5.17.x is the current LTS-ish series
// at the time of writing and works against OpenAPI 3.0 specs.
// Pin the package version and asset integrity together. The SRI hashes
// below are SHA-384 over files from the integrity-verified npm package.
// Browsers must reject modified CDN assets before they can read API tokens.
const swaggerVersion = "5.17.14"
// Escape the title in case it ever grows HTML-sensitive chars
// — today it's plain ASCII but defense-in-depth costs nothing.
Expand All @@ -109,16 +109,19 @@ func renderSwaggerUI(title string) string {
<meta charset="utf-8">
<title>%s</title>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui.css">
href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui.css"
integrity="sha384-wxLW6kwyHktdDGr6Pv1zgm/VGJh99lfUbzSn6HNHBENZlCN7W602k9VkGdxuFvPn" crossorigin="anonymous">
<style>
body { margin: 0; background: #fafafa; }
.topbar { display: none; }
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui-bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui-standalone-preset.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui-bundle.js"
integrity="sha384-wmyclcVGX/WhUkdkATwhaK1X1JtiNrr2EoYJ+diV3vj4v6OC5yCeSu+yW13SYJep" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui-standalone-preset.js"
integrity="sha384-2YH8WDRaj7V2OqU/trsmzSagmk/E2SutiCsGkdgoQwC9pNUJV1u/141DHB6jgs8t" crossorigin="anonymous"></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
Expand Down
46 changes: 4 additions & 42 deletions internal/adapter/docsui/openapi/ra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0.html

servers:
- url: http://localhost:18080/v2
description: Local dev — quickstart ra-local.yaml
- url: https://api.ans.example.org/v2
description: Main ANS API server (v2)
- url: https://test.ans.example.org/v2
description: Test server (v2)
- url: /v2
description: This Registration Authority (current service origin)
Comment thread
csnitker-godaddy marked this conversation as resolved.
Resolved

tags:
- name: Management
Expand Down Expand Up @@ -96,10 +92,8 @@ paths:
# ──────────────────────────────────────────────────────────────────
/v1/agents/events:
servers:
- url: http://localhost:18080
description: Local dev — quickstart ra-local.yaml (feed is not under /v2)
- url: https://api.ans.example.org
description: Main ANS API server
- url: /
description: This Registration Authority (current service origin)
get:
tags:
- Events
Expand Down Expand Up @@ -2847,38 +2841,6 @@ components:
- title
- status

Problem:
type: object
description: |
RFC 7807 Problem Details — the actual error shape every RA failure
path emits, served as `application/problem+json`. Clients read
`code` for programmatic handling and `detail` for the
human-readable explanation.

(The legacy `ErrorResponse` schema below is retained only for the
pre-existing routes still declared against it; new routes point
here. Migrating the remaining declarations is tracked separately.)
properties:
type:
type: string
description: URI reference identifying the problem type.
title:
type: string
description: Short, human-readable summary of the problem type.
status:
type: integer
description: HTTP status code.
detail:
type: string
description: Human-readable explanation specific to this occurrence.
code:
type: string
description: Stable, machine-readable error code for programmatic handling.
required:
- title
- status
- code

ErrorResponse:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions internal/adapter/docsui/openapi/tl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ info:
expose single-record lookup).

servers:
- url: http://localhost:18081
description: local dev (quickstart)
- url: /
description: This Transparency Log (current service origin)

# ────────────────────────────────────────────────────────────────
# Tags group routes in generated docs by audience.
Expand Down
4 changes: 2 additions & 2 deletions spec/api-spec-tl-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ info:
expose single-record lookup).

servers:
- url: http://localhost:18081
description: local dev (quickstart)
- url: /
description: This Transparency Log (current service origin)

# ────────────────────────────────────────────────────────────────
# Tags group routes in generated docs by audience.
Expand Down
46 changes: 4 additions & 42 deletions spec/api-spec-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0.html

servers:
- url: http://localhost:18080/v2
description: Local dev — quickstart ra-local.yaml
- url: https://api.ans.example.org/v2
description: Main ANS API server (v2)
- url: https://test.ans.example.org/v2
description: Test server (v2)
- url: /v2
Comment thread
csnitker-godaddy marked this conversation as resolved.
Resolved
description: This Registration Authority (current service origin)
Comment thread
csnitker-godaddy marked this conversation as resolved.
Resolved

tags:
- name: Management
Expand Down Expand Up @@ -96,10 +92,8 @@ paths:
# ──────────────────────────────────────────────────────────────────
/v1/agents/events:
servers:
- url: http://localhost:18080
description: Local dev — quickstart ra-local.yaml (feed is not under /v2)
- url: https://api.ans.example.org
description: Main ANS API server
- url: /
description: This Registration Authority (current service origin)
get:
tags:
- Events
Expand Down Expand Up @@ -2847,38 +2841,6 @@ components:
- title
- status

Problem:
type: object
description: |
RFC 7807 Problem Details — the actual error shape every RA failure
path emits, served as `application/problem+json`. Clients read
`code` for programmatic handling and `detail` for the
human-readable explanation.

(The legacy `ErrorResponse` schema below is retained only for the
pre-existing routes still declared against it; new routes point
here. Migrating the remaining declarations is tracked separately.)
properties:
type:
type: string
description: URI reference identifying the problem type.
title:
type: string
description: Short, human-readable summary of the problem type.
status:
type: integer
description: HTTP status code.
detail:
type: string
description: Human-readable explanation specific to this occurrence.
code:
type: string
description: Stable, machine-readable error code for programmatic handling.
required:
- title
- status
- code

ErrorResponse:
type: object
properties:
Expand Down
Loading