File tree Expand file tree Collapse file tree 8 files changed +263
-0
lines changed Expand file tree Collapse file tree 8 files changed +263
-0
lines changed Original file line number Diff line number Diff line change @@ -220,8 +220,17 @@ export default async function load(
220220 return `external["${ relativeURL } "]["${ parts . join ( '"]["' ) } "]` ; // export external ref
221221 }
222222
223+ // References to properties of schemas like `#/components/schemas/Pet/properties/name`
224+ // requires the components to be wrapped in a `properties` object. But to keep
225+ // backwards compatibility we should instead just remove the `properties` part.
226+ // For us to recognize the `properties` part it simply has to be the second last.
227+ if ( parts [ parts . length - 2 ] === "properties" ) {
228+ parts . splice ( parts . length - 2 , 1 ) ;
229+ }
230+
223231 // scenario 3: transform all $refs pointing back to root schema
224232 const [ base , ...rest ] = parts ;
233+
225234 return `${ base } ["${ rest . join ( '"]["' ) } "]` ; // transform other $refs to the root schema (including external refs that point back to the root schema)
226235 } ) ;
227236
Original file line number Diff line number Diff line change 1+ /**
2+ * This file was auto-generated by openapi-typescript.
3+ * Do not make direct changes to the file.
4+ */
5+
6+ export interface paths {
7+ readonly "/pet" : {
8+ readonly post : operations [ "addPet" ] ;
9+ } ;
10+ }
11+
12+ export interface definitions {
13+ readonly Pet : {
14+ readonly id ?: number ;
15+ readonly name : string ;
16+ } ;
17+ }
18+
19+ export interface operations {
20+ readonly addPet : {
21+ readonly parameters : {
22+ readonly body : {
23+ readonly body : {
24+ readonly name ?: definitions [ "Pet" ] [ "name" ] ;
25+ } ;
26+ } ;
27+ } ;
28+ readonly responses : {
29+ readonly 200 : unknown ;
30+ } ;
31+ } ;
32+ }
33+
34+ export interface external { }
Original file line number Diff line number Diff line change 1+ /**
2+ * This file was auto-generated by openapi-typescript.
3+ * Do not make direct changes to the file.
4+ */
5+
6+ export interface paths {
7+ "/pet" : {
8+ post : operations [ "addPet" ] ;
9+ } ;
10+ }
11+
12+ export interface definitions {
13+ Pet : {
14+ id ?: number ;
15+ name : string ;
16+ } ;
17+ }
18+
19+ export interface operations {
20+ addPet : {
21+ parameters : {
22+ body : {
23+ body : {
24+ name ?: definitions [ "Pet" ] [ "name" ] ;
25+ } ;
26+ } ;
27+ } ;
28+ responses : {
29+ 200 : unknown ;
30+ } ;
31+ } ;
32+ }
33+
34+ export interface external { }
Original file line number Diff line number Diff line change 1+ swagger : " 2.0"
2+ info :
3+ description : " "
4+ version : " 1.0.0"
5+ title : " Swagger Petstore"
6+ termsOfService : " http://swagger.io/terms/"
7+ contact :
8+ email : " apiteam@swagger.io"
9+ license :
10+ name : " Apache 2.0"
11+ url : " http://www.apache.org/licenses/LICENSE-2.0.html"
12+ paths :
13+ /pet :
14+ post :
15+ operationId : " addPet"
16+ consumes :
17+ - " application/json"
18+ produces :
19+ - " application/json"
20+ parameters :
21+ - in : " body"
22+ name : " body"
23+ description : " "
24+ required : true
25+ schema :
26+ properties :
27+ name :
28+ $ref : " #/definitions/Pet/properties/name"
29+ responses :
30+ 200 :
31+ description : " "
32+ definitions :
33+ Pet :
34+ type : " object"
35+ required :
36+ - " name"
37+ properties :
38+ id :
39+ type : " integer"
40+ format : " int64"
41+ name :
42+ type : " string"
43+ example : " doggie"
Original file line number Diff line number Diff line change 1+ /**
2+ * This file was auto-generated by openapi-typescript.
3+ * Do not make direct changes to the file.
4+ */
5+
6+ export interface paths {
7+ "/pet" : {
8+ put : operations [ "updatePet" ] ;
9+ } ;
10+ }
11+
12+ export interface components {
13+ schemas : {
14+ Pet : {
15+ name : string ;
16+ } & { [ key : string ] : any } ;
17+ } ;
18+ }
19+
20+ export interface operations {
21+ updatePet : {
22+ responses : {
23+ 200 : unknown ;
24+ } ;
25+ requestBody : {
26+ content : {
27+ "application/json" : {
28+ name ?: components [ "schemas" ] [ "Pet" ] [ "name" ] ;
29+ } & { [ key : string ] : any } ;
30+ } ;
31+ } ;
32+ } ;
33+ }
34+
35+ export interface external { }
Original file line number Diff line number Diff line change 1+ /**
2+ * This file was auto-generated by openapi-typescript.
3+ * Do not make direct changes to the file.
4+ */
5+
6+ export interface paths {
7+ readonly "/pet" : {
8+ readonly put : operations [ "updatePet" ] ;
9+ } ;
10+ }
11+
12+ export interface components {
13+ readonly schemas : {
14+ readonly Pet : {
15+ readonly name : string ;
16+ } ;
17+ } ;
18+ }
19+
20+ export interface operations {
21+ readonly updatePet : {
22+ readonly responses : {
23+ readonly 200 : unknown ;
24+ } ;
25+ readonly requestBody : {
26+ readonly content : {
27+ readonly "application/json" : {
28+ readonly name ?: components [ "schemas" ] [ "Pet" ] [ "name" ] ;
29+ } ;
30+ } ;
31+ } ;
32+ } ;
33+ }
34+
35+ export interface external { }
Original file line number Diff line number Diff line change 1+ /**
2+ * This file was auto-generated by openapi-typescript.
3+ * Do not make direct changes to the file.
4+ */
5+
6+ export interface paths {
7+ "/pet" : {
8+ put : operations [ "updatePet" ] ;
9+ } ;
10+ }
11+
12+ export interface components {
13+ schemas : {
14+ Pet : {
15+ name : string ;
16+ } ;
17+ } ;
18+ }
19+
20+ export interface operations {
21+ updatePet : {
22+ responses : {
23+ 200 : unknown ;
24+ } ;
25+ requestBody : {
26+ content : {
27+ "application/json" : {
28+ name ?: components [ "schemas" ] [ "Pet" ] [ "name" ] ;
29+ } ;
30+ } ;
31+ } ;
32+ } ;
33+ }
34+
35+ export interface external { }
Original file line number Diff line number Diff line change 1+ openapi : 3.0.1
2+ info :
3+ title : Spec with reference to proeprties
4+ description : ' '
5+ termsOfService : http://swagger.io/terms/
6+ contact :
7+ email : apiteam@swagger.io
8+ license :
9+ name : Apache 2.0
10+ url : http://www.apache.org/licenses/LICENSE-2.0.html
11+ version : 1.0.0
12+ paths :
13+ /pet :
14+ put :
15+ summary : ' '
16+ operationId : updatePet
17+ requestBody :
18+ description : ' '
19+ content :
20+ application/json :
21+ schema :
22+ properties :
23+ name :
24+ $ref : ' #/components/schemas/Pet/properties/name'
25+ required : true
26+ responses :
27+ 200 :
28+ description : ' '
29+ content : {}
30+ components :
31+ schemas :
32+ Pet :
33+ required :
34+ - name
35+ type : object
36+ properties :
37+ name :
38+ type : string
You can’t perform that action at this time.
0 commit comments