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/jest.config.ts b/packages/parser/jest.config.ts index aeeb621f2..15b688f8d 100644 --- a/packages/parser/jest.config.ts +++ b/packages/parser/jest.config.ts @@ -18,7 +18,7 @@ const config: Config.InitialOptions = { // Test spec file resolution pattern // Matches parent folder `__tests__` and filename - // should contain `test` or `spec`. + // should contain `btest` or `spec`. testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', // Module file extensions for importing moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], diff --git a/packages/parser/package.json b/packages/parser/package.json index cc7006f62..23159ed95 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -80,7 +80,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..65ad526c8 100644 --- a/packages/parser/src/models/v2/server.ts +++ b/packages/parser/src/models/v2/server.ts @@ -34,6 +34,13 @@ 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..f1deec83c 100644 --- a/packages/parser/src/models/v3/server.ts +++ b/packages/parser/src/models/v3/server.ts @@ -26,7 +26,6 @@ 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/src/spec-types/v3.ts b/packages/parser/src/spec-types/v3.ts index 766df3bf9..b0d482354 100644 --- a/packages/parser/src/spec-types/v3.ts +++ b/packages/parser/src/spec-types/v3.ts @@ -42,6 +42,7 @@ export type ServersObject = Record; export interface ServerObject extends SpecificationExtensions { host: string; protocol: string; + summary?: string; pathname?: string; protocolVersion?: string; description?: string; diff --git a/packages/parser/test/models/v2/server.spec.ts b/packages/parser/test/models/v2/server.spec.ts index bb98877ba..4c2c3e6ea 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,18 @@ 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); + }); + }); + 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..b0b425140 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,18 @@ 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); + }); + }); + describe('.host()', function () { it('should return value', function () { expect(docItem.host()).toEqual(doc.production.host);