From a680dd716b042e104d0bea776372b829de19b51d Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Thu, 30 Jan 2025 11:34:09 +0100 Subject: [PATCH] fix: behaviour for downloadUrls and extend examples to description file --- demo/museum.yaml | 6 ++++++ demo/playground/hmr-playground.tsx | 6 +++++- src/components/ApiInfo/ApiInfo.tsx | 2 +- src/services/models/ApiInfo.ts | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/demo/museum.yaml b/demo/museum.yaml index 8473be69..ccbed4d2 100644 --- a/demo/museum.yaml +++ b/demo/museum.yaml @@ -309,6 +309,9 @@ components: enum: - event - general + x-enumDescriptions: + event: Special event ticket + general: General museum entry ticket example: event Date: type: string @@ -776,6 +779,9 @@ x-tagGroups: - name: Purchases tags: - Tickets + - name: Entities + tags: + - schemas security: - MuseumPlaceholderAuth: [] diff --git a/demo/playground/hmr-playground.tsx b/demo/playground/hmr-playground.tsx index 16bb507b..85944828 100644 --- a/demo/playground/hmr-playground.tsx +++ b/demo/playground/hmr-playground.tsx @@ -11,7 +11,11 @@ const userUrl = window.location.search.match(/url=(.*)$/); const specUrl = (userUrl && userUrl[1]) || (swagger ? 'museum.yaml' : big ? 'big-openapi.json' : 'museum.yaml'); -const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 3 }; +const options: RedocRawOptions = { + nativeScrollbars: false, + maxDisplayedEnumValues: 3, + schemaDefinitionsTagName: 'schemas', +}; const container = document.getElementById('example'); const root = createRoot(container!); diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index 6c25c695..75e00438 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -88,7 +88,7 @@ export class ApiInfo extends React.Component { rel="noreferrer" key={url} > - {downloadUrls.length > 1 ? title : l('download')} + {title} ); })} diff --git a/src/services/models/ApiInfo.ts b/src/services/models/ApiInfo.ts index 325161fe..db6d3fa5 100644 --- a/src/services/models/ApiInfo.ts +++ b/src/services/models/ApiInfo.ts @@ -46,7 +46,7 @@ export class ApiInfoModel implements OpenAPIInfo { }, ] : this.options.downloadUrls.map(({ title, url }) => ({ - title: title || 'Download OpenAPI description', + title: title || l('download'), url: this.getDownloadLink(url), })) ).filter(({ title, url }) => title && url);