From 7dee3e717d954eea827da3416a67ba81111017fb Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Tue, 20 May 2025 14:14:36 -0700 Subject: [PATCH 1/2] Redoc: Fixed issue with margins on API pages --- assets/css/v2/style.css | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/css/v2/style.css b/assets/css/v2/style.css index d26547f..25db856 100644 --- a/assets/css/v2/style.css +++ b/assets/css/v2/style.css @@ -688,12 +688,16 @@ nav { } .api { - margin: 2rem 0 2rem 2rem; - width: 100%; + margin: 0 0 1rem 1rem; .row { display: grid !important; } + .breadcrumb-layout { + width: auto; + margin-top: 2rem; + } + .nginx-docs-api-container { grid-column: 1 / -1 !important; max-width: 100% !important; From 9fea180d373cc85346a5933bef5e36891daa5880 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 21 May 2025 07:51:35 -0700 Subject: [PATCH 2/2] Redoc: Added example to exampleSite --- assets/css/v2/style.css | 3 +- .../content/test-product/redoc/_index.md | 6 ++ .../test-product/redoc/api-reference.md | 11 ++ exampleSite/static/api/example.json | 98 +++++++++++++++++ layouts/redoc/single.html | 100 ++++++++++++++++++ 5 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 exampleSite/content/test-product/redoc/_index.md create mode 100644 exampleSite/content/test-product/redoc/api-reference.md create mode 100644 exampleSite/static/api/example.json create mode 100644 layouts/redoc/single.html diff --git a/assets/css/v2/style.css b/assets/css/v2/style.css index 25db856..7f5abd7 100644 --- a/assets/css/v2/style.css +++ b/assets/css/v2/style.css @@ -699,8 +699,9 @@ nav { } .nginx-docs-api-container { - grid-column: 1 / -1 !important; + grid-column: 1 / -1; max-width: 100% !important; + margin-top: 2rem; } .content-layout { diff --git a/exampleSite/content/test-product/redoc/_index.md b/exampleSite/content/test-product/redoc/_index.md new file mode 100644 index 0000000..b930484 --- /dev/null +++ b/exampleSite/content/test-product/redoc/_index.md @@ -0,0 +1,6 @@ +--- +description: Redocly API usage +title: Redocly +weight: 300 +toc: true +--- diff --git a/exampleSite/content/test-product/redoc/api-reference.md b/exampleSite/content/test-product/redoc/api-reference.md new file mode 100644 index 0000000..6f24b96 --- /dev/null +++ b/exampleSite/content/test-product/redoc/api-reference.md @@ -0,0 +1,11 @@ +--- +description: How API's from redocly are rendered for an example book API +title: API Reference +weight: 200 +type: redoc +tags: + - api +doctypes: + - reference +--- +{{< openapi spec="./api/example.json" >}} diff --git a/exampleSite/static/api/example.json b/exampleSite/static/api/example.json new file mode 100644 index 0000000..3a469e3 --- /dev/null +++ b/exampleSite/static/api/example.json @@ -0,0 +1,98 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Simple Book API", + "version": "v1", + "description": "A simple API to manage books." + }, + "paths": { + "/books": { + "get": { + "summary": "Get all books", + "responses": { + "200": { + "description": "List of books", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + }, + "post": { + "summary": "Add a new book", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Book" + } + } + } + }, + "responses": { + "201": { + "description": "Book added" + } + } + } + }, + "/books/{id}": { + "get": { + "summary": "Get a book by ID", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Book found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Book" + } + } + } + }, + "404": { + "description": "Book not found" + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + }, + "required": ["id", "title", "author"] + } + } + } + } + \ No newline at end of file diff --git a/layouts/redoc/single.html b/layouts/redoc/single.html new file mode 100644 index 0000000..665217c --- /dev/null +++ b/layouts/redoc/single.html @@ -0,0 +1,100 @@ +{{ define "main" }} + + + + +
+ +
+ + +
+
{{ .Content}}
+
+
+ +{{ end }}