diff --git a/package-lock.json b/package-lock.json index 18999f4f0..c92ee114c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7268,6 +7268,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "license": "MIT", "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -12313,7 +12314,7 @@ "eslint-plugin-github": "^4.3.7", "eslint-plugin-security": "^1.5.0", "eslint-plugin-sonarjs": "^0.15.0", - "jest": "^29.0.2", + "jest": "^29.7.0", "markdown-toc": "^1.2.0", "path-browserify": "^1.0.1", "puppeteer": "^17.1.1", diff --git a/packages/parser/src/models/server.ts b/packages/parser/src/models/server.ts index 52e2ece50..594934613 100644 --- a/packages/parser/src/models/server.ts +++ b/packages/parser/src/models/server.ts @@ -9,6 +9,8 @@ import type { SecurityRequirementsInterface } from './security-requirements'; export interface ServerInterface extends BaseModel, DescriptionMixinInterface, BindingsMixinInterface, ExtensionsMixinInterface, TagsMixinInterface { id(): string url(): string; + summary(): string | undefined; + hasSummary(): boolean; host(): string; hasPathname(): boolean; pathname(): string | undefined; diff --git a/packages/parser/src/models/v2/server.ts b/packages/parser/src/models/v2/server.ts index 10521fad2..a506eb6e7 100644 --- a/packages/parser/src/models/v2/server.ts +++ b/packages/parser/src/models/v2/server.ts @@ -34,6 +34,14 @@ export class Server extends BaseModel implement url(): string { return this._json.url; } + + summary(): string | undefined { + return this._json.summary; + } + + hasSummary(): boolean { + return !!this._json.summary; + } host(): string { const url = new URL(this.url()); diff --git a/packages/parser/src/models/v3/server.ts b/packages/parser/src/models/v3/server.ts index 9308882dc..4f7acd95f 100644 --- a/packages/parser/src/models/v3/server.ts +++ b/packages/parser/src/models/v3/server.ts @@ -26,7 +26,7 @@ export class Server extends CoreModel implement id(): string { return this._meta.id; } - + url(): string { let host = this.host(); if (!host.endsWith('/')) { diff --git a/packages/parser/src/spec-types/v2.ts b/packages/parser/src/spec-types/v2.ts index 758cd3035..f10df4ff6 100644 --- a/packages/parser/src/spec-types/v2.ts +++ b/packages/parser/src/spec-types/v2.ts @@ -41,6 +41,7 @@ export type ServersObject = Record; export interface ServerObject extends SpecificationExtensions { url: string; protocol: string; + summary?: string; protocolVersion?: string; description?: string; variables?: Record; diff --git a/packages/parser/test/models/v2/server.spec.ts b/packages/parser/test/models/v2/server.spec.ts index bb98877ba..3588a2c31 100644 --- a/packages/parser/test/models/v2/server.spec.ts +++ b/packages/parser/test/models/v2/server.spec.ts @@ -17,6 +17,7 @@ import { SecurityRequirement } from '../../../src/models/v2/security-requirement const doc = { development: { protocol: 'mqtt', + summary: 'mqtt development server is summary', protocolVersion: '1.0.0', url: 'development.gigantic-server.com', variables: { @@ -43,6 +44,21 @@ describe('Server Model', function () { }); }); + describe('.summary()', function () { + it('should return value', function () { + expect(docItem.summary()).toEqual(doc.development.summary); + }); + }); + + describe('.hasSummary()', function () { + it('should return true if summary is present', function () { + expect(docItem.hasSummary()).toEqual(true); + }); + it('should return false if summary is missing', function () { + expect(emptyItem.hasSummary()).toEqual(false); + }); + }); + describe('.hasProtocolVersion()', function () { it('should return true if protocolVersion is not missing', function () { expect(docItem.hasProtocolVersion()).toBeTruthy(); diff --git a/packages/parser/test/models/v3/server.spec.ts b/packages/parser/test/models/v3/server.spec.ts index 2669bc8dd..948224842 100644 --- a/packages/parser/test/models/v3/server.spec.ts +++ b/packages/parser/test/models/v3/server.spec.ts @@ -18,6 +18,7 @@ import { xParserObjectUniqueId } from '../../../src/constants'; const doc = { production: { host: 'rabbitmq.in.mycompany.com:5672', + summary: 'rabbitmq production server is summary', pathname: '/production', protocol: 'amqp', protocolVersion: '1.0.0', @@ -45,6 +46,21 @@ describe('Server Model', function () { }); }); + describe('.summary()', function () { + it('should return value', function () { + expect(docItem.summary()).toEqual(doc.production.summary); + }); + }); + + describe('.hasSummary()', function () { + it('should return true if summary is present', function () { + expect(docItem.hasSummary()).toEqual(true); + }); + it('should return false if summary is missing', function () { + expect(emptyItem.hasSummary()).toEqual(false); + }); + }); + describe('.host()', function () { it('should return value', function () { expect(docItem.host()).toEqual(doc.production.host);