mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
feat: add summary and indentifier to license
This commit is contained in:
parent
17d05667af
commit
33ddbbd9f0
|
@ -38,7 +38,7 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
const license =
|
||||
(info.license && (
|
||||
<InfoSpan>
|
||||
License: <a href={info.license.url}>{info.license.name}</a>
|
||||
License: {info.license.identifier ? info.license.identifier : (<a href={info.license.url}>{info.license.name}</a>)}
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
@ -100,7 +100,8 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
)) ||
|
||||
null}
|
||||
</StyledMarkdownBlock>
|
||||
<Markdown source={store.spec.info.description} data-role="redoc-description" />
|
||||
<Markdown source={store.spec.info.description} data-role="redoc-description"/>
|
||||
<Markdown source={store.spec.info.summary} data-role="redoc-summary"/>
|
||||
{externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
|
||||
</MiddlePanel>
|
||||
</Row>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
2
src/types/open-api.d.ts
vendored
2
src/types/open-api.d.ts
vendored
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user