File tree Expand file tree Collapse file tree 6 files changed +39
-39
lines changed
openapi-ts-tests/main/test Expand file tree Collapse file tree 6 files changed +39
-39
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @hey-api/openapi-ts ' : patch
3
+ ---
4
+
5
+ fix(parser): bump support for OpenAPI 3.1.2
Original file line number Diff line number Diff line change @@ -34,11 +34,11 @@ export default defineConfig(() => {
34
34
// },
35
35
path : path . resolve (
36
36
getSpecsPath ( ) ,
37
- '3.0 .x' ,
38
- 'circular.yaml' ,
37
+ '3.1 .x' ,
38
+ // 'circular.yaml',
39
39
// 'invalid',
40
40
// 'openai.yaml',
41
- // 'full.yaml',
41
+ 'full.yaml' ,
42
42
// 'opencode.yaml',
43
43
// 'sdk-instance.yaml',
44
44
// 'string-with-format.yaml',
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ export type Package = {
27
27
) => boolean ;
28
28
} ;
29
29
30
+ export const satisfies : typeof semver . satisfies = ( ...args ) =>
31
+ semver . satisfies ( ...args ) ;
32
+
30
33
export const packageFactory = (
31
34
dependencies : Record < string , string > ,
32
35
) : Package => ( {
@@ -47,6 +50,6 @@ export const packageFactory = (
47
50
typeof nameOrVersion === 'string'
48
51
? dependencies [ nameOrVersion ]
49
52
: nameOrVersion ;
50
- return version ? semver . satisfies ( version , range , optionsOrLoose ) : false ;
53
+ return version ? satisfies ( version , range , optionsOrLoose ) : false ;
51
54
} ,
52
55
} ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export interface OpenApiV3_1_X {
25
25
/**
26
26
* **REQUIRED**. This string MUST be the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#versions version number} of the OpenAPI Specification that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling to interpret the OpenAPI document. This is _not_ related to the API {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#infoVersion `info.version`} string.
27
27
*/
28
- openapi : '3.1.0' | '3.1.1' ;
28
+ openapi : '3.1.0' | '3.1.1' | '3.1.2' ;
29
29
/**
30
30
* The available paths and operations for the API.
31
31
*/
Original file line number Diff line number Diff line change
1
+ import { satisfies } from '../config/utils/package' ;
1
2
import { IRContext } from '../ir/context' ;
2
3
import type { IR } from '../ir/types' ;
3
4
import type { Config } from '../types/config' ;
@@ -85,20 +86,14 @@ export const parseOpenApiSpec = ({
85
86
return context ;
86
87
}
87
88
88
- switch ( context . spec . openapi ) {
89
- case '3.0.0' :
90
- case '3.0.1' :
91
- case '3.0.2' :
92
- case '3.0.3' :
93
- case '3.0.4' :
94
- parseV3_0_X ( context as IR . Context < OpenApi . V3_0_X > ) ;
95
- return context ;
96
- case '3.1.0' :
97
- case '3.1.1' :
98
- parseV3_1_X ( context as IR . Context < OpenApi . V3_1_X > ) ;
99
- return context ;
100
- default :
101
- break ;
89
+ if ( satisfies ( context . spec . openapi , '>=3.0.0 <3.1.0' ) ) {
90
+ parseV3_0_X ( context as IR . Context < OpenApi . V3_0_X > ) ;
91
+ return context ;
92
+ }
93
+
94
+ if ( satisfies ( context . spec . openapi , '>=3.1.0' ) ) {
95
+ parseV3_1_X ( context as IR . Context < OpenApi . V3_1_X > ) ;
96
+ return context ;
102
97
}
103
98
104
99
throw new Error ( 'Unsupported OpenAPI specification' ) ;
Original file line number Diff line number Diff line change
1
+ import { satisfies } from '../../../config/utils/package' ;
1
2
import type { IR } from '../../../ir/types' ;
2
3
import type { OpenApiV2_0_XTypes } from '../../../openApi/2.0.x' ;
3
4
import type { OpenApiV3_0_XTypes } from '../../../openApi/3.0.x' ;
@@ -461,25 +462,21 @@ export const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => {
461
462
return ;
462
463
}
463
464
464
- switch ( plugin . context . spec . openapi ) {
465
- case '3.0.0' :
466
- case '3.0.1' :
467
- case '3.0.2' :
468
- case '3.0.3' :
469
- case '3.0.4' :
470
- schemasV3_0_X ( {
471
- context : plugin . context as IR . Context < OpenApi . V3_0_X > ,
472
- plugin,
473
- } ) ;
474
- break ;
475
- case '3.1.0' :
476
- case '3.1.1' :
477
- schemasV3_1_X ( {
478
- context : plugin . context as IR . Context < OpenApi . V3_1_X > ,
479
- plugin,
480
- } ) ;
481
- break ;
482
- default :
483
- throw new Error ( 'Unsupported OpenAPI specification' ) ;
465
+ if ( satisfies ( plugin . context . spec . openapi , '>=3.0.0 <3.1.0' ) ) {
466
+ schemasV3_0_X ( {
467
+ context : plugin . context as IR . Context < OpenApi . V3_0_X > ,
468
+ plugin,
469
+ } ) ;
470
+ return ;
484
471
}
472
+
473
+ if ( satisfies ( plugin . context . spec . openapi , '>=3.1.0' ) ) {
474
+ schemasV3_1_X ( {
475
+ context : plugin . context as IR . Context < OpenApi . V3_1_X > ,
476
+ plugin,
477
+ } ) ;
478
+ return ;
479
+ }
480
+
481
+ throw new Error ( 'Unsupported OpenAPI specification' ) ;
485
482
} ;
You can’t perform that action at this time.
0 commit comments