Skip to content

Commit 4032bec

Browse files
committed
fix: adding mnissing server description
Signed-off-by: Pawel Psztyc <[email protected]>
1 parent 76486ce commit 4032bec

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/amf-helper-mixin",
33
"description": "A mixin with common functions user by most AMF components to compute AMF values",
4-
"version": "4.5.13",
4+
"version": "4.5.14",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/AmfSerializer.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
292292
* @returns {ApiServer} Serialized Server
293293
*/
294294
server(object) {
295-
const url = this._getValue(object, this.ns.aml.vocabularies.core.urlTemplate) || '';
295+
const { ns } = this;
296+
const url = this._getValue(object, ns.aml.vocabularies.core.urlTemplate) || '';
296297
const result = /** @type ApiServer */ ({
297298
id: object['@id'],
298299
types: object['@type'].map(this[expandKey].bind(this)),
@@ -301,19 +302,23 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
301302
customDomainProperties: this.customDomainProperties(object),
302303
sourceMaps: this.sourceMap(object),
303304
});
304-
const variables = /** @type Parameter[] */ (object[this._getAmfKey(this.ns.aml.vocabularies.apiContract.variable)]);
305+
const description = this._getValue(object, ns.aml.vocabularies.core.description);
306+
if (description && typeof description === 'string') {
307+
result.description = description;
308+
}
309+
const variables = /** @type Parameter[] */ (object[this._getAmfKey(ns.aml.vocabularies.apiContract.variable)]);
305310
if (Array.isArray(variables) && variables.length) {
306311
result.variables = variables.map((p) => this.parameter(p));
307312
}
308-
const protocol = /** @type string */ (this._getValue(object, this.ns.aml.vocabularies.apiContract.protocol));
309-
const protocolVersion = /** @type string */ (this._getValue(object, this.ns.aml.vocabularies.apiContract.protocolVersion));
313+
const protocol = /** @type string */ (this._getValue(object, ns.aml.vocabularies.apiContract.protocol));
314+
const protocolVersion = /** @type string */ (this._getValue(object, ns.aml.vocabularies.apiContract.protocolVersion));
310315
if (protocol) {
311316
result.protocol = protocol;
312317
}
313318
if (protocolVersion) {
314319
result.protocolVersion = protocolVersion;
315320
}
316-
const security = /** @type SecurityRequirement */ (object[this._getAmfKey(this.ns.aml.vocabularies.security.security)]);
321+
const security = /** @type SecurityRequirement */ (object[this._getAmfKey(ns.aml.vocabularies.security.security)]);
317322
if (Array.isArray(security) && security.length) {
318323
result.security = security.map((p) => this.securityRequirement(p));
319324
}

test/serializer/Server.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ describe('AmfSerializer', () => {
4646
assert.typeOf(v1, 'object', 'the variable is an object');
4747
assert.include(v1.types, serializer.ns.aml.vocabularies.apiContract.Parameter, 'has the Parameter type');
4848
});
49+
50+
it('has the description', () => {
51+
const result = serializer.server(servers[1]);
52+
assert.equal(result.description, 'Staging server');
53+
});
4954
});
5055

5156
describe('Async API', () => {

0 commit comments

Comments
 (0)