Skip to content

Commit fbaecdb

Browse files
committed
Add defaults, dynamically generate back to docs link, and change RDI API to use the generic api layout
1 parent 8877a67 commit fbaecdb

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
Title: RDI API Reference
3-
layout: rdiapireference
2+
linkTitle: RDI API Reference
3+
Title: Redis Data Integration API
4+
layout: apireference
45
type: page
56
---

content/operate/rc/api/api-reference.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Title: Redis Cloud API
33
linkTitle: API reference
44
layout: apireference
55
type: page
6-
params:
7-
sourcefile: ./openapi.json
86
---

layouts/_default/apireference.html

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
11
<!DOCTYPE html>
22
<html>
3+
<!--
4+
This layout can be used to generate API docs from an OpenAPI specification.
5+
6+
When creating a new API reference page, you can specify these optional params in the front matter:
7+
- sourcefile: The path to the OpenAPI specification file (YAML or JSON) relative to the page. Default: ./openapi.json
8+
- backLink: The path to the page to link to in the top left corner. Default: Parent page
9+
10+
Here's what the file structure should look like to use this template:
11+
<containing-folder>/
12+
├---------api-reference/
13+
| └------<spec-file-name> (default openapi.json)
14+
|
15+
├---------api-reference.md
16+
|
17+
└---------<other files>
18+
19+
Here's what the api-reference.md front matter should look like:
20+
---
21+
Title: <API Name>
22+
linkTitle: API reference
23+
layout: apireference
24+
type: page
25+
params:
26+
sourcefile: ./<spec-file-name> (optional - only specify if not using ./openapi.json)
27+
backLink: <path-to-page> (optional - only specify if not using the parent page)
28+
---
29+
30+
Example usage for the Redis Cloud API with all params set:
31+
---
32+
Title: Redis Cloud API
33+
linkTitle: API reference
34+
layout: apireference
35+
type: page
36+
params:
37+
sourcefile: ./openapi.json
38+
backLink: operate/rc/api
39+
---
40+
-->
341

442
<head>
543
<title>{{ .Title }}</title>
644
{{ partial "scss.html" (dict "path" "scss/style.scss") }}
745
{{ partial "css.html" (dict "path" "css/index.css") }}
8-
{{ $relref := printf "%s%s" .Site.BaseURL "operate/rc/api/" }}
46+
{{ $relref := .Parent.Permalink }}
47+
{{ if .Params.backLink}}
48+
{{ $relref = printf "%s%s" .Site.BaseURL .Params.backLink }}
49+
{{ end }}
950
<!-- needed for adaptive design -->
1051
<!-- <link rel="preload" href="/public/scss/style.min.65324e4de191c292ee8b6f4f0ebf01320e8c4bc8623b04e9dfad322ebb490b31.css" as="style">
1152
<link href="/public/scss/style.min.65324e4de191c292ee8b6f4f0ebf01320e8c4bc8623b04e9dfad322ebb490b31.css" rel="stylesheet" integrity="">
@@ -62,7 +103,7 @@
62103
<body>
63104
<div>
64105
<redoc
65-
spec-url='{{ .Params.sourcefile }}'
106+
spec-url='{{ .Params.sourcefile | default "./openapi.json" }}'
66107
scroll-y-offset='#apiReferenceHeader'
67108
json-sample-expand-level=all
68109
sort-operations-alphabetically="true"

0 commit comments

Comments
 (0)