Skip to content

Commit 90e3bab

Browse files
committed
feat: Add OasBundleService for bundling OpenAPI documents
- Implemented OasBundleService to bundle OpenAPI specifications with resolved references. - Introduced helper functions for guessing file extensions and deriving document names. - Enhanced error handling for bundling failures. feat: Update OasConversionService to support target version - Added functionality to specify target version for OpenAPI conversion. - Improved version normalization and error handling for unsupported versions. refactor: Remove OasDereferenceService - Deleted OasDereferenceService as its functionality is now integrated into OasBundleService. feat: Introduce OasGeneratorService for generating OpenAPI documents - Created OasGeneratorService to generate boilerplate OpenAPI documents from JSON input. - Added validation for required fields in the generator configuration. refactor: Update ToolsService to use new services - Replaced OasDereferenceService with OasBundleService in ToolsService. - Integrated OasGeneratorService for generating OpenAPI documents. - Updated method signatures and error handling for new service implementations.
1 parent 036e92f commit 90e3bab

12 files changed

Lines changed: 1059 additions & 2174 deletions

api/openapi.json

Lines changed: 309 additions & 163 deletions
Large diffs are not rendered by default.

api/openapi.yaml

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ tags:
1818
- description: Conversies en hulpmiddelen
1919
name: Tools
2020
paths:
21-
/v1/arazzo/parse:
21+
/v1/arazzo/markdown:
2222
post:
23-
description: "Converteert een OpenAPI Arazzo specificatie naar Markdown en Mermaid.\
24-
\ Body: { arazzoUrl|arazzoBody }"
25-
operationId: arazzo
23+
description: "Genereert alleen de Markdown-uitvoer van een Arazzo specificatie.\
24+
\ Body: { oasUrl|oasBody }"
25+
operationId: arazzoMarkdown
2626
requestBody:
2727
content:
2828
application/json:
@@ -31,9 +31,9 @@ paths:
3131
responses:
3232
"200":
3333
content:
34-
application/json:
34+
text/markdown:
3535
schema:
36-
$ref: "#/components/schemas/ModelsArazzoVisualization"
36+
type: string
3737
description: OK
3838
headers:
3939
API-Version:
@@ -48,25 +48,26 @@ paths:
4848
- apiKey: []
4949
clientCredentials:
5050
- tools
51-
summary: Visualiseer Arazzo (POST)
51+
summary: Arazzo Markdown (POST)
5252
tags:
5353
- Tools
5454
x-eov-operation-handler: controllers/ToolsController
55-
/v1/auth/clients:
55+
/v1/arazzo/mermaid:
5656
post:
57-
description: Maak een client aan via de admin API. Body bevat Email.
58-
operationId: untrustClient
57+
description: "Genereert alleen de Mermaid flowchart van een Arazzo specificatie.\
58+
\ Body: { oasUrl|oasBody }"
59+
operationId: arazzoMermaid
5960
requestBody:
6061
content:
6162
application/json:
6263
schema:
63-
$ref: "#/components/schemas/UntrustClientInput"
64+
$ref: "#/components/schemas/OASInput"
6465
responses:
6566
"200":
6667
content:
67-
application/json:
68+
text/plain:
6869
schema:
69-
$ref: "#/components/schemas/ModelsKeycloakClientResult"
70+
type: string
7071
description: OK
7172
headers:
7273
API-Version:
@@ -81,22 +82,25 @@ paths:
8182
- apiKey: []
8283
clientCredentials:
8384
- tools
84-
summary: Maak client (POST)
85+
summary: Arazzo Mermaid (POST)
8586
tags:
8687
- Tools
8788
x-eov-operation-handler: controllers/ToolsController
88-
/v1/bruno/convert:
89+
/v1/auth/clients:
8990
post:
90-
description: "Converteert OpenAPI naar Bruno ZIP. Body: { oasUrl } of { oasBody\
91-
\ } (stringified JSON of YAML)."
92-
operationId: CreateBrunoCollection
91+
description: Maak een client aan via de admin API. Body bevat Email.
92+
operationId: untrustClient
9393
requestBody:
9494
content:
9595
application/json:
9696
schema:
97-
$ref: "#/components/schemas/OASInput"
97+
$ref: "#/components/schemas/UntrustClientInput"
9898
responses:
9999
"200":
100+
content:
101+
application/json:
102+
schema:
103+
$ref: "#/components/schemas/ModelsKeycloakClientResult"
100104
description: OK
101105
headers:
102106
API-Version:
@@ -111,14 +115,15 @@ paths:
111115
- apiKey: []
112116
clientCredentials:
113117
- tools
114-
summary: Maak Bruno-collectie (POST)
118+
summary: Maak client (POST)
115119
tags:
116120
- Tools
117121
x-eov-operation-handler: controllers/ToolsController
118122
/v1/oas/convert:
119123
post:
120-
description: "Zet OpenAPI 3.0 om naar 3.1 of andersom. Body: { oasUrl } of {\
121-
\ oasBody } (stringified JSON of YAML)."
124+
description: "Converteert OpenAPI naar de laatst ondersteunde versie (standaard\
125+
\ 3.1). Meegegeven targetVersion (3.0 of 3.1) bepaalt het doel. Body: { oasUrl\
126+
\ } of { oasBody } (stringified JSON of YAML)."
122127
operationId: ConvertOAS
123128
requestBody:
124129
content:
@@ -145,11 +150,11 @@ paths:
145150
tags:
146151
- Tools
147152
x-eov-operation-handler: controllers/ToolsController
148-
/v1/oas/dereference:
153+
/v1/oas/bundle:
149154
post:
150-
description: "Haalt externe $ref verwijzingen op en levert één compleet OpenAPI\
151-
\ document terug. Body: { oasUrl } of { oasBody }."
152-
operationId: DereferenceOAS
155+
description: "Bundelt een OpenAPI specificatie en lost externe verwijzingen\
156+
\ op. Body: { oasUrl } of { oasBody }."
157+
operationId: bundleOAS
153158
requestBody:
154159
content:
155160
application/json:
@@ -171,14 +176,14 @@ paths:
171176
- apiKey: []
172177
clientCredentials:
173178
- tools
174-
summary: Dereference OpenAPI
179+
summary: Bundle OpenAPI
175180
tags:
176181
- Tools
177182
x-eov-operation-handler: controllers/ToolsController
178183
/v1/oas/generate:
179184
post:
180-
description: "Zet OpenAPI 3.0 om naar 3.1 of andersom. Body: { oasUrl } of {\
181-
\ oasBody } (stringified JSON of YAML)."
185+
description: "Genereert een boilerplate OpenAPI specificatie op basis van JSON-invoer.\
186+
\ Body: { oasUrl } of { oasBody } (stringified JSON)."
182187
operationId: GenerateOAS
183188
requestBody:
184189
content:
@@ -195,6 +200,10 @@ paths:
195200
schema:
196201
type: string
197202
style: simple
203+
content:
204+
application/json:
205+
schema:
206+
type: object
198207
"404":
199208
description: Not Found
200209
security:
@@ -239,7 +248,7 @@ paths:
239248
tags:
240249
- Tools
241250
x-eov-operation-handler: controllers/ToolsController
242-
/v1/postman/convert:
251+
/v1/oas/postman:
243252
post:
244253
description: "Converteert OpenAPI naar Postman Collection JSON. Body: { oasUrl\
245254
\ } of { oasBody } (stringified JSON of YAML)."
@@ -289,20 +298,14 @@ components:
289298
example:
290299
oasUrl: oasUrl
291300
oasBody: oasBody
301+
targetVersion: "3.1"
292302
properties:
293303
oasBody:
294304
type: string
295305
oasUrl:
296306
type: string
297-
type: object
298-
ModelsArazzoVisualization:
299-
example:
300-
mermaid: mermaid
301-
markdown: markdown
302-
properties:
303-
markdown:
304-
type: string
305-
mermaid:
307+
targetVersion:
308+
description: Doelversie voor conversie (momenteel 3.0 of 3.1).
306309
type: string
307310
type: object
308311
ModelsKeycloakClientResult:

controllers/ToolsController.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
const Controller = require("./Controller");
1010
const service = require("../services/ToolsService");
1111

12-
const arazzo = async (request, response) => {
13-
await Controller.handleRequest(request, response, service.arazzo);
12+
const arazzoMarkdown = async (request, response) => {
13+
await Controller.handleRequest(request, response, service.arazzoMarkdown);
1414
};
1515

16-
const convertOAS = async (request, response) => {
17-
await Controller.handleRequest(request, response, service.convertOAS);
16+
const arazzoMermaid = async (request, response) => {
17+
await Controller.handleRequest(request, response, service.arazzoMermaid);
1818
};
1919

20-
const createBrunoCollection = async (request, response) => {
21-
await Controller.handleRequest(request, response, service.createBrunoCollection);
20+
const convertOAS = async (request, response) => {
21+
await Controller.handleRequest(request, response, service.convertOAS);
2222
};
2323

2424
const createPostmanCollection = async (request, response) => {
2525
await Controller.handleRequest(request, response, service.createPostmanCollection);
2626
};
2727

28-
const dereferenceOAS = async (request, response) => {
29-
await Controller.handleRequest(request, response, service.dereferenceOAS);
28+
const bundleOAS = async (request, response) => {
29+
await Controller.handleRequest(request, response, service.bundleOAS);
3030
};
3131

3232
const generateOAS = async (request, response) => {
@@ -42,11 +42,11 @@ const validatorOpenAPIPost = async (request, response) => {
4242
};
4343

4444
module.exports = {
45-
arazzo,
45+
arazzoMarkdown,
46+
arazzoMermaid,
4647
convertOAS,
47-
createBrunoCollection,
4848
createPostmanCollection,
49-
dereferenceOAS,
49+
bundleOAS,
5050
generateOAS,
5151
untrustClient,
5252
validatorOpenAPIPost,

expressServer.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,9 @@ class ExpressServer {
140140
res.set("API-Version", this.schema.info.version);
141141
next();
142142
});
143-
this.app.get("/openapi.json", (_req, res) => res.json(this.schema));
144-
this.app.get("/login-redirect", (req, res) => {
145-
res.status(200);
146-
res.json(req.query);
147-
});
148-
this.app.get("/oauth2-redirect.html", (req, res) => {
149-
res.status(200);
150-
res.json(req.query);
151-
});
143+
const sendOpenApiSpec = (_req, res) => res.json(this.schema);
144+
this.app.get("/openapi.json", sendOpenApiSpec);
145+
this.app.get("/v1/openapi", sendOpenApiSpec);
152146
this.app.use(
153147
OpenApiValidator.middleware({
154148
apiSpec: this.schema,

0 commit comments

Comments
 (0)