Skip to content

Commit 0713d7c

Browse files
committed
Use @redocly/cli
1 parent 49c226a commit 0713d7c

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

download-openapi.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ for v in v1 v2 v3 v4 v5 v6; do \
44
curl -s http://192.168.58.25/cgi-bin/mt/mt-data-api.cgi/${v}/ \
55
| jq '.servers[0].url = "https://example.com/mt/mt-data-api.cgi/v1"' \
66
| jq -S . > src/openapi/${v}.json; \
7+
perl json2yaml.pl ${f} > src/openapi/`basename ${f} json`yaml; \
78
done

json2yaml.pl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
use feature qw/say/;
6+
use JSON;
7+
use YAML;
8+
use Data::Dumper; $Data::Dumper::Indent = 1;
9+
10+
my $filename = $ARGV[0];
11+
12+
exit 1 unless $filename;
13+
14+
open my $fh, '<', $filename;
15+
my $file = do { local $/; <$fh> };
16+
close $fh;
17+
18+
my $json = JSON::decode_json($file);
19+
local $YAML::Stringify = 1;
20+
my $yaml = Dump($json);
21+
say $yaml;

redoc-build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/sh
22

33
for v in v1 v2 v3 v4 v5 v6; do \
4-
npx redoc-cli build src/openapi/${v}.json \
4+
npx @redocly/cli build-docs src/openapi/${v}.yaml \
55
--template src/openapi/data-api-redoc.hbs \
66
--disableGoogleFont \
77
--title "Movable Type Data API ${v}" \
88
--templateOptions.metaDescription "Movable Type Data API ${v}" \
9-
--options.sortTagsAlphabetically=true \
9+
--config redoc.config.yaml \
1010
--output docs/${v}.html; \
1111
done

redoc.config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
theme:
2+
openapi:
3+
sortTagsAlphabetically: true

0 commit comments

Comments
 (0)