@@ -49,7 +49,9 @@ import { AmfHelperMixin, expandKey, findAmfType, getArrayItems } from "./AmfHelp
49
49
/** @typedef {import('./types').ApiDataNodeUnion } ApiDataNodeUnion */
50
50
/** @typedef {import('./types').ApiDocumentSourceMaps } ApiDocumentSourceMaps */
51
51
/** @typedef {import('./types').ApiSynthesizedField } ApiSynthesizedField */
52
+ /** @typedef {import('./types').ApiParametrizedDeclaration } ApiParametrizedDeclaration */
52
53
/** @typedef {import('./types').ApiParametrizedTrait } ApiParametrizedTrait */
54
+ /** @typedef {import('./types').ApiParametrizedResourceType } ApiParametrizedResourceType */
53
55
/** @typedef {import('./types').ApiVariableValue } ApiVariableValue */
54
56
/** @typedef {import('./types').ApiAbstractDeclaration } ApiAbstractDeclaration */
55
57
/** @typedef {import('./types').ShapeProcessingOptions } ShapeProcessingOptions */
@@ -106,7 +108,9 @@ import { AmfHelperMixin, expandKey, findAmfType, getArrayItems } from "./AmfHelp
106
108
/** @typedef {import('./amf').Tag } Tag */
107
109
/** @typedef {import('./amf').DocumentSourceMaps } DocumentSourceMaps */
108
110
/** @typedef {import('./amf').SynthesizedField } SynthesizedField */
111
+ /** @typedef {import('./amf').ParametrizedDeclaration } ParametrizedDeclaration */
109
112
/** @typedef {import('./amf').ParametrizedTrait } ParametrizedTrait */
113
+ /** @typedef {import('./amf').ParametrizedResourceType } ParametrizedResourceType */
110
114
/** @typedef {import('./amf').VariableValue } VariableValue */
111
115
/** @typedef {import('./amf').AbstractDeclaration } AbstractDeclaration */
112
116
/** @typedef {import('./amf').Organization } Organization */
@@ -1303,6 +1307,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
1303
1307
payloads : [ ] ,
1304
1308
servers : [ ] ,
1305
1309
security : [ ] ,
1310
+ extends : [ ] ,
1306
1311
} ) ;
1307
1312
const { ns } = this ;
1308
1313
const path = this . _getValue ( object , ns . aml . vocabularies . apiContract . path ) ;
@@ -1341,6 +1346,21 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
1341
1346
if ( Array . isArray ( security ) && security . length ) {
1342
1347
result . security = security . map ( i => this . securityRequirement ( i ) ) ;
1343
1348
}
1349
+ const extensions = this [ getArrayItems ] ( object , ns . aml . vocabularies . document . extends ) ;
1350
+ if ( Array . isArray ( extensions ) && extensions . length ) {
1351
+ result . extends = [ ] ;
1352
+ extensions . forEach ( ( ex ) => {
1353
+ let extension = ex ;
1354
+ if ( Array . isArray ( extension ) ) {
1355
+ [ extension ] = extension ;
1356
+ }
1357
+ if ( this . _hasType ( extension , ns . aml . vocabularies . apiContract . ParametrizedResourceType ) ) {
1358
+ result . extends . push ( this . parametrizedResourceType ( extension ) ) ;
1359
+ } else if ( this . _hasType ( extension , ns . aml . vocabularies . apiContract . ParametrizedTrait ) ) {
1360
+ result . extends . push ( this . parametrizedTrait ( extension ) ) ;
1361
+ }
1362
+ } ) ;
1363
+ }
1344
1364
return result ;
1345
1365
}
1346
1366
@@ -1364,7 +1384,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
1364
1384
schemes : [ ] ,
1365
1385
contentType : [ ] ,
1366
1386
tags : [ ] ,
1367
- traits : [ ] ,
1387
+ extends : [ ] ,
1368
1388
} ) ;
1369
1389
const { ns } = this ;
1370
1390
const method = this . _getValue ( object , ns . aml . vocabularies . apiContract . method ) ;
@@ -1440,7 +1460,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
1440
1460
}
1441
1461
const traits = object [ this . _getAmfKey ( ns . aml . vocabularies . document . extends ) ] ;
1442
1462
if ( Array . isArray ( traits ) && traits . length ) {
1443
- result . traits = traits . map ( t => this . parametrizedTrait ( t ) ) ;
1463
+ result . extends = traits . map ( t => this . parametrizedTrait ( t ) ) ;
1444
1464
}
1445
1465
return result ;
1446
1466
}
@@ -2102,11 +2122,11 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
2102
2122
}
2103
2123
2104
2124
/**
2105
- * @param {ParametrizedTrait } object
2106
- * @returns {ApiParametrizedTrait }
2125
+ * @param {ParametrizedDeclaration } object
2126
+ * @returns {ApiParametrizedDeclaration }
2107
2127
*/
2108
- parametrizedTrait ( object ) {
2109
- const result = /** @type ApiParametrizedTrait */ ( {
2128
+ parametrizedDeclaration ( object ) {
2129
+ const result = /** @type ApiParametrizedDeclaration */ ( {
2110
2130
id : object [ '@id' ] ,
2111
2131
types : object [ '@type' ] . map ( this [ expandKey ] . bind ( this ) ) ,
2112
2132
variables : [ ] ,
@@ -2132,6 +2152,24 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
2132
2152
return result ;
2133
2153
}
2134
2154
2155
+ /**
2156
+ * @param {ParametrizedTrait } object
2157
+ * @returns {ApiParametrizedTrait }
2158
+ */
2159
+ parametrizedTrait ( object ) {
2160
+ const result = /** @type ApiParametrizedTrait */ ( this . parametrizedDeclaration ( object ) ) ;
2161
+ return result ;
2162
+ }
2163
+
2164
+ /**
2165
+ * @param {ParametrizedResourceType } object
2166
+ * @returns {ApiParametrizedResourceType }
2167
+ */
2168
+ parametrizedResourceType ( object ) {
2169
+ const result = /** @type ApiParametrizedResourceType */ ( this . parametrizedDeclaration ( object ) ) ;
2170
+ return result ;
2171
+ }
2172
+
2135
2173
/**
2136
2174
* @param {VariableValue } object
2137
2175
* @returns {ApiVariableValue }
0 commit comments