Skip to content

Commit afe61f3

Browse files
lamATnginxnginx-jack
authored andcommitted
Redoc: Added example to exampleSite
1 parent ab6f97d commit afe61f3

File tree

5 files changed

+217
-1
lines changed

5 files changed

+217
-1
lines changed

assets/css/v2/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,9 @@ nav {
699699
}
700700

701701
.nginx-docs-api-container {
702-
grid-column: 1 / -1 !important;
702+
grid-column: 1 / -1;
703703
max-width: 100% !important;
704+
margin-top: 2rem;
704705
}
705706

706707
.content-layout {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description: Redocly API usage
3+
title: Redocly
4+
weight: 300
5+
toc: true
6+
---
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: How API's from redocly are rendered for an example book API
3+
title: API Reference
4+
weight: 200
5+
type: redoc
6+
tags:
7+
- api
8+
doctypes:
9+
- reference
10+
---
11+
{{< openapi spec="./api/example.json" >}}

exampleSite/static/api/example.json

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"openapi": "3.0.3",
3+
"info": {
4+
"title": "Simple Book API",
5+
"version": "v1",
6+
"description": "A simple API to manage books."
7+
},
8+
"paths": {
9+
"/books": {
10+
"get": {
11+
"summary": "Get all books",
12+
"responses": {
13+
"200": {
14+
"description": "List of books",
15+
"content": {
16+
"application/json": {
17+
"schema": {
18+
"type": "array",
19+
"items": {
20+
"$ref": "#/components/schemas/Book"
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
},
28+
"post": {
29+
"summary": "Add a new book",
30+
"requestBody": {
31+
"required": true,
32+
"content": {
33+
"application/json": {
34+
"schema": {
35+
"$ref": "#/components/schemas/Book"
36+
}
37+
}
38+
}
39+
},
40+
"responses": {
41+
"201": {
42+
"description": "Book added"
43+
}
44+
}
45+
}
46+
},
47+
"/books/{id}": {
48+
"get": {
49+
"summary": "Get a book by ID",
50+
"parameters": [
51+
{
52+
"name": "id",
53+
"in": "path",
54+
"required": true,
55+
"schema": {
56+
"type": "string"
57+
}
58+
}
59+
],
60+
"responses": {
61+
"200": {
62+
"description": "Book found",
63+
"content": {
64+
"application/json": {
65+
"schema": {
66+
"$ref": "#/components/schemas/Book"
67+
}
68+
}
69+
}
70+
},
71+
"404": {
72+
"description": "Book not found"
73+
}
74+
}
75+
}
76+
}
77+
},
78+
"components": {
79+
"schemas": {
80+
"Book": {
81+
"type": "object",
82+
"properties": {
83+
"id": {
84+
"type": "string"
85+
},
86+
"title": {
87+
"type": "string"
88+
},
89+
"author": {
90+
"type": "string"
91+
}
92+
},
93+
"required": ["id", "title", "author"]
94+
}
95+
}
96+
}
97+
}
98+

layouts/redoc/single.html

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{{ define "main" }}
2+
3+
<!-- Remove upon cleaning up old frame code -->
4+
<style>
5+
.nginx-docs-api-container {
6+
z-index: 0 !important;
7+
max-width: calc(100% + 2.4rem);
8+
margin-top: 2rem;
9+
}
10+
11+
@media (min-width: 768px) {
12+
.nginx-docs-api-container {
13+
z-index: 0 !important;
14+
max-width: calc(75% + 2.4rem);
15+
}
16+
}
17+
18+
html {
19+
scroll-behavior: auto !important;
20+
}
21+
22+
.menu-content {
23+
top: 0 !important;
24+
height: 100vh !important;
25+
}
26+
.bCOLCR {
27+
background: #e6e6e6;
28+
}
29+
.fTsuzH {
30+
background-color: #e6e6e6;
31+
}
32+
.fgRoXk {
33+
background-color: #fafafa;
34+
}
35+
#api-component > api-container > redoc {
36+
background-color: #e6e6e6;
37+
}
38+
div.sc-jSFjdj.sc-gKAaRy.dYGhuI.fTsuzH > div > h3 {
39+
color: #000000;
40+
}
41+
div.sc-dvUynV.fgRoXk.redoc-wrap {
42+
margin-left: -15px;
43+
margin-right: -15px;
44+
}
45+
.gKPxXE .collapser {
46+
background-color: transparent !important;
47+
}
48+
div
49+
> div.sc-jSFjdj.sc-gKAaRy.dYGhuI.fTsuzH
50+
> div.sc-EZqKI.iONckA
51+
> button:hover {
52+
background-color: #003963;
53+
}
54+
div > div.sc-giAqHp.hIuvjA > button:hover {
55+
color: #003963;
56+
}
57+
.nginx-docs-api-container button:hover {
58+
background-color: rgb(237, 237, 237);
59+
}
60+
pre {
61+
white-space: pre-wrap;
62+
}
63+
</style>
64+
<!--Use wide page layout for the API reference pages-->
65+
<section class="main-layout api">
66+
<div class="sidebar-layout" data-mf="true" style="display:none;">
67+
<nav id="sidebar-v2" class="sidebar">
68+
{{ partial "sidebar-v2.html" . }}
69+
</nav>
70+
</div>
71+
<div
72+
class="row flex-md-nowrap content-layout"
73+
style="
74+
position: relative;
75+
flex-wrap: nowrap;
76+
margin-right: 9px;
77+
max-width: calc(100% + 9px);
78+
"
79+
>
80+
<nav
81+
id="sidebar"
82+
class="sidenav overflow-auto col-md-3 d-none d-md-block d-print-none sidebar-toggle-hidden-width"
83+
style="width: 25%; border-right: 1px solid #e6e6e6"
84+
;
85+
>
86+
{{ partial "sidebar.html" . }}
87+
</nav>
88+
<section class="breadcrumb-layout" data-mf="true" style="display: none;">
89+
{{ if not .IsHome }}
90+
{{ if not (in .Params.display_breadcrumb "false" ) }}
91+
{{ partial "breadcrumb" .}}
92+
{{ end }}
93+
{{ end }}
94+
</section>
95+
<div class="nginx-docs-api-container">
96+
<div id="api-component">{{ .Content}}</div>
97+
</div>
98+
</section>
99+
</div>
100+
{{ end }}

0 commit comments

Comments
 (0)