Skip to content

Commit f9f88ea

Browse files
committed
ci: remove internally marked variables
The bundled and filtered spec hosted on pages should be used for SDK- and documentation-generation instead of the raw one.
1 parent 8752f6f commit f9f88ea

File tree

6 files changed

+4076
-64
lines changed

6 files changed

+4076
-64
lines changed
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const id = 'remove-internal';
2+
3+
/** @type {import('@redocly/openapi-cli').CustomRulesConfig} */
4+
const decorators = {
5+
oas3: {
6+
'remove-internal': () => {
7+
return {
8+
PathItem: {
9+
leave(pathItem, ctx) {
10+
// delete if the path itself is marked with x-internal
11+
if (pathItem['x-internal']) {
12+
delete ctx.parent[ctx.key];
13+
}
14+
15+
// delete any operations inside of a path marked with x-internal
16+
const operations = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'];
17+
for (const operation of operations) {
18+
if (pathItem[operation] && pathItem[operation]['x-internal']) {
19+
delete pathItem[operation];
20+
}
21+
}
22+
23+
// delete the path if there are no operations remaining in it
24+
if (Object.keys(pathItem).length === 0) {
25+
delete ctx.parent[ctx.key];
26+
}
27+
}
28+
},
29+
Parameter: {
30+
leave(parameter, ctx) {
31+
// delete if the parameter itself is marked with x-internal
32+
if (parameter['x-internal']) {
33+
delete ctx.parent[ctx.key];
34+
}
35+
}
36+
},
37+
SchemaProperties: {
38+
leave(properties, ctx) {
39+
for (const [key, object] of Object.entries(properties)) {
40+
//console.log(`${key}: ${object}`);
41+
if (object['x-internal']) {
42+
delete properties[key];
43+
}
44+
}
45+
}
46+
}
47+
}
48+
},
49+
},
50+
};
51+
52+
module.exports = {
53+
id,
54+
decorators,
55+
};

.github/workflows/ci.yaml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
on: [push, pull_request]
2-
name: Continuous Integration
2+
name: OpenAPI Specification CI
33

44
jobs:
55
lint:
@@ -24,18 +24,24 @@ jobs:
2424

2525
bundle:
2626
runs-on: ubuntu-latest
27-
name: Bundle OpenAPI specification
27+
name: Bundle and Upload OpenAPI specification
2828
steps:
2929
- uses: actions/checkout@v2
3030

31-
- name: OpenAPI CLI Bundle
31+
- name: Bundle OpenAPI Specification 📦
3232
uses: hilary/[email protected]
3333
with:
34-
base-spec: openapi.yaml
34+
base-spec: openapi/openapi.yaml
3535
bundled-spec: dist/openapi-bundled.yml
3636

37-
- name: Store bundled specification
37+
- name: Upload Bundled Specification as Artifact 📤
3838
uses: actions/upload-artifact@v2
3939
with:
4040
name: openapi-bundled
41-
path: dist/openapi-bundled.yml
41+
path: dist/openapi-bundled.yml
42+
43+
- name: Deploy Bundle to Github Pages 🚀
44+
uses: JamesIves/[email protected]
45+
with:
46+
branch: master
47+
folder: dist

.redocly.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See https://redoc.ly/docs/cli/configuration/ for more information.
2+
apiDefinitions:
3+
main: openapi/openapi.yaml
4+
lint:
5+
extends:
6+
- recommended
7+
plugins:
8+
- './.github/redocly-plugins/remove-internal.js'
9+
decorators:
10+
remove-internal/remove-internal: error

0 commit comments

Comments
 (0)