Skip to content

Commit ea6862c

Browse files
committed
restructuring repo
1 parent 8d26b4a commit ea6862c

File tree

8 files changed

+5996
-11
lines changed

8 files changed

+5996
-11
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ jobs:
3232
if [[ $CIRCLE_BRANCH == 'master' ]]; then
3333
chmod +x ./auth_gcloud.sh
3434
./auth_gcloud.sh
35-
gsutil -h "Cache-Control:public,max-age=3600" -m rsync -a public-read -d -r ./config/ gs://bluecore-openapi-docs/config_files/
36-
gsutil -h "Cache-Control:public,max-age=3600" -m rsync -a public-read -d -r ./css/ gs://bluecore-openapi-docs/css_files/
35+
gsutil -h "Cache-Control:public,max-age=3600" -m rsync -a public-read -d -r ./apis/ gs://bluecore-openapi-docs/
3736
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,104 @@
1-
# Bluecore APIs OpenAPI Config Files
1+
# Bluecore OpenAPI Docs
2+
This repository contains the files necessary to configure Bluecore API docs following Open API 3.0 specifications.
23

3-
This repository contains the code that supports serving the Bluecore Transactional API documentation using Redoc.
4+
Currently, the only the [Bluecore Transactional API Docs](https://www.bluecore.com/transactional-api-docs/) are live.
5+
6+
7+
## Config Files
8+
OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including:
9+
10+
- Available endpoints (e.g. `/users`) and operations on each endpoint (`GET /users`, `POST /users`, etc.)
11+
- Operation parameters Input and output for each operation
12+
- Authentication methods
13+
- Contact information, license, terms of use and other information.
14+
15+
API specifications are written in YAML. The format is easy to learn and readable to both humans and machines. The complete OpenAPI Specification can be found on GitHub: [OpenAPI 3.0 Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)
16+
17+
18+
## Redoc
19+
The API specification YAML file is parsed by [Redoc](https://github.com/Redocly/redoc) - an open-source tool that generates the front-end components for our API docs.
20+
21+
To render API documentation using Redoc, all you need to do is add Redoc's `<script>` tag on the page, along with a `<redoc>` tag pointing to the API specification YAML file.
22+
23+
e.g. HTML
24+
```
25+
<body>
26+
<redoc spec-url='https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/transactional-api%2Ftransactional_api.yaml?alt=media' hide-download-button></redoc>
27+
28+
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
29+
</body>
30+
```
31+
32+
33+
## Hosting
34+
Currently, docs are hosted on `www.bluecore.com/`, where our public-facing marketing pages live. API Docs are added as custom pages on Bluecore's Wordpress set up.
35+
36+
We chose to host the API Docs on Wordpress mainly because this was a solution that was free and quick to stand up. It is not a perfect solution and the recommendation would be to look for a better hosting solution for Bluecore's public API documentation.
37+
38+
39+
## Deployment
40+
Whenever changes are merged into `master` on GitHub, CircleCI will take the files in `./apis` and upload them to a public Google Cloud Storage bucket (specifically [bluecore-openapi-docs](https://console.cloud.google.com/storage/browser/bluecore-openapi-docs;tab=objects?forceOnBucketsSortingFiltering=false&project=triggeredmail&prefix=&forceOnObjectsSortingFiltering=false)).
41+
42+
The corresponding Wordpress page pulls the config YAML file from Google Cloud Storage.
43+
E.g. from the Wordpress set up of the Bluecore Transactional API Docs
44+
```
45+
<!-- YAML config file -->
46+
<redoc spec-url='https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/config_files%2Ftransactional_api.yaml?alt=media' hide-download-button></redoc>
47+
48+
<!-- Redoc script -->
49+
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
50+
```
51+
52+
When any changes are merged, all of the files in `./apis` will be deployed to GCS, and those changes will be reflected the next time the browser is loaded.
53+
54+
55+
## Next Steps
56+
Short Term:
57+
- Gather feedback from internal users
58+
- Migrate the Bluecore Transactional API docs on KB to the new doc
59+
60+
Long Term:
61+
- Identify other external APIs that need updated API docs
62+
- Identify a better enterprise hosting solution for docs. The current solution of hosting our API docs on the marketing website is not ideal. There are limitations on Wordpress, such as URL structure for when we push up multiple pages, unconfigurable links in the nav bar and marketing bot widgets, etc.
63+
64+
65+
## How Do I Add New API Doc Pages?
66+
Follow the steps below to create new docs for another Bluecore API:
67+
68+
#### Make a Config File
69+
Make a new directory in `./apis/` with the name of the API (e.g. `mobile-events-api-v1`).
70+
In that folder, create a YAML config file following Open API 3.0 specifications.
71+
You can also add a CSS file for custom styling for this page.
72+
73+
To view locally, edit the `<redoc>` tag in `./index.html` to reference your new config file:
74+
```
75+
<redoc spec-url='./apis/mobile-events-api-v1/config.yaml' hide-download-button></redoc>
76+
```
77+
78+
Then run `yarn open-redoc` from the command line. This will open up a live server on localhost using the contents of `index.html`. Any saved changes will cause the page to re-load with the new content.
79+
80+
81+
#### Set Up the Wordpress Page
82+
In Wordpress, add a new page on using the "API Docs" Wordpress template. You can set the page's URL to `your-api-name`.
83+
You will need admin access on Wordpress to complete this step (contact the Marketing team if you need access).
84+
85+
The page contents should include the `<script>` tag to load Redoc on the page along with the `<redoc>` tag that references your API's YAML config file. You can also include a `<link>` tag to load custom CSS.
86+
87+
```
88+
<!-- CSS -->
89+
<link type="text/css" rel="stylesheet" href="https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/css_files%2Ftransactional_api.css?alt=media">
90+
91+
<!-- YAML config file -->
92+
<redoc spec-url='https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/config_files%2Ftransactional_api.yaml?alt=media' hide-download-button></redoc>
93+
94+
<!-- Redoc script -->
95+
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
96+
```
97+
98+
The `href` and `spec-url`s follow Google Cloud Storage's URL format for [downloading Cloud Storage objects](https://cloud.google.com/storage/docs/downloading-objects).
99+
100+
101+
#### Deploy to GCS
102+
Merge to master and verify your new docs have been deployed by going to [Google Cloud Storage](https://console.cloud.google.com/storage/browser/bluecore-openapi-docs;tab=objects?forceOnBucketsSortingFiltering=false&project=triggeredmail&prefix=&forceOnObjectsSortingFiltering=false) and looking for your files.
103+
104+
Finally, go to the live page on www.bluecore.com/your-api-here and check the live version of your docs!

index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Bluecore Transactional API</title>
4+
<title>Local Bluecore API page</title>
55
<meta charset="utf-8"/>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
8-
<!-- Live CSS FILE -->
9-
<!-- <link type="text/css" rel="stylesheet" href="https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/css_files%2Ftransactional_api.css?alt=media"> -->
8+
9+
<!-- LIVE CSS FILE -->
10+
<!-- <link type="text/css" rel="stylesheet" href="https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/transactional-api%2Ftransactional_api.css?alt=media"> -->
1011
<!-- LOCAL CSS FILE -->
11-
<link type="text/css" rel="stylesheet" href="./css/transactional_api.css">
12+
<link type="text/css" rel="stylesheet" href="./apis/transactional-api/transactional_api.css">
1213
</head>
1314
<body>
1415
<!-- LIVE CONFIG FILE -->
15-
<!-- <redoc spec-url='https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/config_files%2Ftransactional_api.yaml?alt=media' hide-download-button></redoc> -->
16+
<!-- <redoc spec-url='https://storage.googleapis.com/download/storage/v1/b/bluecore-openapi-docs/o/transactional-api%2Ftransactional_api.yaml?alt=media' hide-download-button></redoc> -->
1617

1718
<!-- LOCAL CONFIG FILE -->
18-
<redoc spec-url='./config/transactional_api.yaml' hide-download-button></redoc>
19+
<redoc spec-url='./apis/transactional-api/transactional_api.yaml' hide-download-button></redoc>
20+
1921
<!-- Redoc script that parses config file and generates frontend -->
2022
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
2123
</body>

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"devDependencies": {},
1414
"scripts": {
15-
"edit": "openapi-editor --file ./config/transactional_api.yaml --port 8080",
1615
"open-redoc": "live-server"
1716
}
1817
}

0 commit comments

Comments
 (0)