Skip to content

Commit

Permalink
[api] switch to use stoplight/elements to render api doc, remove depe…
Browse files Browse the repository at this point in the history
…ndency on npx & redoc-cli for build

Closes: #9778
  • Loading branch information
Xiao Li authored and bors-libra committed Nov 16, 2021
1 parent 535f43d commit c529edb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-post-land.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ jobs:
RUSTDOCFLAGS: "-Z unstable-options --enable-index-page"
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
- name: Build API specification doc into target/doc/diem_api
run : npx redoc-cli bundle api/doc/openapi.yaml -o target/doc/diem_api/spec.html
- name: copy API specification doc into target/doc/diem_api
run : cp api/doc/openapi.yaml target/doc/diem_api/openapi.yaml && cp api/doc/spec.html target/doc/diem_api/spec.html
- name: Deploy Docs
uses: peaceiris/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ test-api-spec:


serve:
npx redoc-cli serve --watch doc/openapi.yaml
cd doc && python -m http.server 8888

.PHONY: test lint test-code-gen test-api-spec clean serve
43 changes: 0 additions & 43 deletions api/build.rs

This file was deleted.

14 changes: 14 additions & 0 deletions api/doc/spec.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Elements in HTML</title>
<!-- Embed elements Elements via Web Component -->
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
</head>
<body>
<elements-api apiDescriptionUrl="openapi.yaml" router="hash" layout="sidebar" hideInternal="true"/>
</body>
</html>
2 changes: 1 addition & 1 deletion api/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use warp::{
reply, Filter, Rejection, Reply,
};

const OPEN_API_HTML: &str = include_str!(concat!(env!("OUT_DIR"), "/spec.html"));
const OPEN_API_HTML: &str = include_str!("../doc/spec.html");
const OPEN_API_SPEC: &str = include_str!("../doc/openapi.yaml");

pub fn routes(context: Context) -> impl Filter<Extract = impl Reply, Error = Infallible> + Clone {
Expand Down
4 changes: 0 additions & 4 deletions docker/build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
# SPDX-License-Identifier: Apache-2.0
set -e

# nodejs is required for building api package
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

#either release or test
if [ -z "$IMAGE_TARGETS" ]; then
IMAGE_TARGETS="all"
Expand Down

0 comments on commit c529edb

Please sign in to comment.