Skip to content

Commit c3ae17a

Browse files
[openapi] task: split source/build OpenAPI lint in CI and upgrade Redocly CLI (#836)
1 parent a777f03 commit c3ae17a

5 files changed

Lines changed: 560 additions & 1186 deletions

File tree

openapi/.redocly.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

openapi/README.md

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,91 @@ The API is implemented in the [`nis`](../nis) module in this repository.
55

66
## Requirements
77

8-
* Node.js 20 LTS
8+
* Node.js 20 LTS or higher
99

10-
## Installation (in the monorepo)
10+
YAML style and syntax for files under `spec/` are checked by the monorepo **Linters** job (`linters/scripts/lint_yaml.sh` -> `yamllint` with `linters/yaml/.yamllint`). Run that from the repository root if you need the same check locally:
1111

12-
From the root of the `nem` repository:
12+
```sh
13+
./linters/scripts/lint_yaml.sh
14+
```
15+
16+
## Installation
17+
18+
1. Clone the monorepo and enter this package.
1319

14-
```bash
15-
cd openapi
20+
```
21+
git clone https://github.com/NemProject/nem.git
22+
cd nem/openapi
23+
```
24+
25+
2. Install dependencies.
26+
27+
```
1628
npm install
1729
```
1830

1931
## Commands
2032

2133
### Build
2234

23-
Compile the OpenAPI specification.
24-
The generated output is saved under the `_build` directory.
35+
Compile the specification. The generated output is saved under the `_build` directory.
2536

26-
```bash
37+
```
2738
npm run build
2839
```
2940

3041
### Test
3142

32-
Check if the specification is valid.
43+
Checks links in the built specification (`_build/openapi3.yml`).
3344

34-
```bash
45+
```
3546
npm run test
36-
```
47+
```
48+
49+
In CI the flow is split into dedicated stages:
50+
51+
- `scripts/ci/lint.sh` -> `npm run lint` (OpenAPI lint on `spec/openapi.yml`)
52+
- `scripts/ci/build.sh` -> `npm run build` (bundle to `_build/openapi3.yml`)
53+
- `scripts/ci/test.sh` -> `npm run test`
54+
55+
### Postman
56+
57+
Generate a Postman collection from the built specification.
58+
59+
```
60+
npm run postman
61+
```
62+
63+
### Release (monorepo)
64+
65+
Release in monorepo is component-scoped (`openapi/`) and produces versioned OpenAPI + Postman artifacts.
66+
67+
1. Bump `version` in `package.json` and update `CHANGELOG.md`.
68+
2. Run publish script:
69+
70+
```
71+
scripts/ci/publish.sh
72+
```
73+
74+
This prepares:
75+
76+
- `_build/openapi3.yml`
77+
- `_build/openapi3.json`
78+
- `_build/postman.json`
79+
- `_build/v<version>/openapi3.yml`
80+
- `_build/v<version>/openapi3.json`
81+
- `_build/v<version>/postman.json`
82+
83+
Optional: create a GitHub release with assets (requires authenticated `gh` CLI):
84+
85+
```sh
86+
OPENAPI_RELEASE_CREATE_GH=1 OPENAPI_RELEASE_TAG=openapi/v<version> scripts/ci/publish.sh
87+
```
88+
89+
## Contributing
90+
91+
Before contributing please [read this](CONTRIBUTING.md).
92+
93+
## License
94+
95+
Licensed under the [Apache License 2.0](LICENSE).

0 commit comments

Comments
 (0)