Skip to content

Commit 69474a8

Browse files
committed
chore: adding OAS 3 to the demo parser
Signed-off-by: Pawel Uchida-Psztyc <[email protected]>
1 parent b8357bf commit 69474a8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

demo/demo-server/api/amf-service/amf-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ const getConfiguration = (vendor) => {
3030
switch (vendor) {
3131
case 'RAML 0.8': return RAMLConfiguration.RAML08();
3232
case 'RAML 1.0': return RAMLConfiguration.RAML10();
33-
case 'OAS 2.0': return OASConfiguration.OAS20();
34-
case 'OAS 3.0': return OASConfiguration.OAS30();
33+
case 'OAS 2.0':
34+
case 'OAS 2':
35+
return OASConfiguration.OAS20();
36+
case 'OAS 3.0':
37+
case 'OAS 3':
38+
return OASConfiguration.OAS30();
3539
case 'ASYNC 2.0': return AsyncAPIConfiguration.Async20();
3640
default: throw new Error(`Unknown vendor: ${vendor}`);
3741
}

demo/demo-server/api/amf-service/api-search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ export class ApiSearch {
132132
await fs.close(fd);
133133
const data = result.buffer.toString().trim();
134134
if (data[0] === '{') {
135-
// OAS 1/2
136-
const match = data.match(/"swagger"(?:\s*)?:(?:\s*)"(.*)"/im);
135+
// OAS 1/2/3
136+
const match = data.match(/"(?:openapi|swagger)"(?:\s*)?:(?:\s*)"([^"])/im);
137137
if (!match) {
138138
throw new Error('Expected OAS but could not find version header.');
139139
}

0 commit comments

Comments
 (0)