diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index 91a1de22..26819db0 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -38,7 +38,7 @@ export class ApiInfo extends React.Component { const license = (info.license && ( - License: {info.license.name} + License: {info.license.identifier ? info.license.identifier : ({info.license.name})} )) || null; @@ -100,7 +100,8 @@ export class ApiInfo extends React.Component { )) || null} - + + {externalDocs && } diff --git a/src/services/AppStore.ts b/src/services/AppStore.ts index 9387c521..76805419 100644 --- a/src/services/AppStore.ts +++ b/src/services/AppStore.ts @@ -145,7 +145,10 @@ export class AppStore { if (idx === -1 && IS_BROWSER) { const $description = document.querySelector('[data-role="redoc-description"]'); + const $summary = document.querySelector('[data-role="redoc-summary"]'); + if ($description) elements.push($description); + if ($summary) elements.push($summary); } this.marker.addOnly(elements); diff --git a/src/services/__tests__/models/ApiInfo.test.ts b/src/services/__tests__/models/ApiInfo.test.ts index 5adb6036..457937ec 100644 --- a/src/services/__tests__/models/ApiInfo.test.ts +++ b/src/services/__tests__/models/ApiInfo.test.ts @@ -34,5 +34,17 @@ describe('Models', () => { const info = new ApiInfoModel(parser); expect(info.description).toEqual('Test description\nsome text\n'); }); + + test('should correctly populate summary up to the first md heading', () => { + parser.spec = { + openapi: '3.1.0', + info: { + summary: 'Test summary\nsome text\n## Heading\n test', + }, + } as any; + + const info = new ApiInfoModel(parser); + expect(info.summary).toEqual('Test summary\nsome text\n## Heading\n test'); + }); }); }); diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index fea480aa..517538db 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -7,6 +7,7 @@ export class ApiInfoModel implements OpenAPIInfo { version: string; description: string; + summary: string; termsOfService?: string; contact?: OpenAPIContact; license?: OpenAPILicense; @@ -17,6 +18,7 @@ export class ApiInfoModel implements OpenAPIInfo { constructor(private parser: OpenAPIParser) { Object.assign(this, parser.spec.info); this.description = parser.spec.info.description || ''; + this.summary = parser.spec.info.summary || ''; const firstHeadingLinePos = this.description.search(/^##?\s+/m); if (firstHeadingLinePos > -1) { diff --git a/src/types/open-api.d.ts b/src/types/open-api.d.ts index f2356326..96f98f36 100644 --- a/src/types/open-api.d.ts +++ b/src/types/open-api.d.ts @@ -18,6 +18,7 @@ export interface OpenAPIInfo { version: string; description?: string; + summary?: string; termsOfService?: string; contact?: OpenAPIContact; license?: OpenAPILicense; @@ -272,4 +273,5 @@ export interface OpenAPIContact { export interface OpenAPILicense { name: string; url?: string; + identifier?: string; }