next-rest-framework
Advanced tools
Comparing version
@@ -31,11 +31,9 @@ import { type OpenAPIV3_1 } from 'openapi-types'; | ||
provider?: DocsProvider; | ||
meta?: { | ||
/*! Custom HTML meta title. */ | ||
title?: string; | ||
/*! Custom HTML meta description. */ | ||
description?: string; | ||
/*! Custom HTML meta favicon URL. */ | ||
faviconUrl?: string; | ||
}; | ||
/*! A URL for a custom logo rendered in the docs. */ | ||
/*! Custom title, used for the visible title and HTML title. */ | ||
title?: string; | ||
/*! Custom description, used for the visible description and HTML meta description. */ | ||
description?: string; | ||
/*! Custom HTML meta favicon URL. */ | ||
faviconUrl?: string; | ||
/*! A URL for a custom logo. */ | ||
logoUrl?: string; | ||
@@ -42,0 +40,0 @@ }; |
@@ -20,7 +20,5 @@ "use strict"; | ||
provider: 'redoc', | ||
meta: { | ||
title: constants_1.DEFAULT_TITLE, | ||
description: constants_1.DEFAULT_DESCRIPTION, | ||
faviconUrl: constants_1.DEFAULT_FAVICON_URL | ||
}, | ||
title: constants_1.DEFAULT_TITLE, | ||
description: constants_1.DEFAULT_DESCRIPTION, | ||
faviconUrl: constants_1.DEFAULT_FAVICON_URL, | ||
logoUrl: constants_1.DEFAULT_LOGO_URL | ||
@@ -27,0 +25,0 @@ }, |
import { type NextRestFrameworkConfig } from '../types'; | ||
export declare const getHtmlForDocs: ({ config: { openApiJsonPath, openApiObject, docsConfig: { provider, meta: { title, description, faviconUrl }, logoUrl } }, baseUrl }: { | ||
export declare const getHtmlForDocs: ({ config: { openApiJsonPath, openApiObject, docsConfig: { provider, title, description, faviconUrl, logoUrl } }, baseUrl }: { | ||
config: NextRestFrameworkConfig; | ||
baseUrl: string; | ||
}) => string; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const constants_1 = require("../constants"); | ||
const getHtmlForDocs = ({ config: { openApiJsonPath, openApiObject, docsConfig: { provider, meta: { title = openApiObject?.info.title ?? constants_1.DEFAULT_TITLE, description = openApiObject?.info.description ?? constants_1.DEFAULT_DESCRIPTION, faviconUrl = constants_1.DEFAULT_FAVICON_URL } = {}, logoUrl = constants_1.DEFAULT_LOGO_URL } = {} }, baseUrl }) => { | ||
const getHtmlForDocs = ({ config: { openApiJsonPath, openApiObject, docsConfig: { provider, title = openApiObject?.info.title ?? constants_1.DEFAULT_TITLE, description = openApiObject?.info.description ?? constants_1.DEFAULT_DESCRIPTION, faviconUrl = constants_1.DEFAULT_FAVICON_URL, logoUrl = constants_1.DEFAULT_LOGO_URL } = {} }, baseUrl }) => { | ||
const url = `${baseUrl}${openApiJsonPath}`; | ||
@@ -28,8 +28,12 @@ const redocHtml = `<!DOCTYPE html> | ||
<script> | ||
fetch('${url}') | ||
.then(res => res.json()) | ||
.then(spec => { | ||
spec.info['x-logo'] = { url: "${logoUrl}" }; | ||
Redoc.init(spec, {}, document.getElementById('redoc')); | ||
}); | ||
window.onload = () => { | ||
fetch('${url}') | ||
.then(res => res.json()) | ||
.then(spec => { | ||
spec.info['title'] = "${title}"; | ||
spec.info['description'] = "${description}"; | ||
spec.info['x-logo'] = { url: "${logoUrl}" }; | ||
Redoc.init(spec, {}, document.getElementById('redoc')); | ||
}); | ||
}; | ||
</script> | ||
@@ -62,15 +66,22 @@ </body> | ||
window.onload = () => { | ||
window.ui = SwaggerUIBundle({ | ||
url: '${url}', | ||
dom_id: '#swagger-ui', | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
layout: 'StandaloneLayout', | ||
deepLinking: true, | ||
displayOperationId: true, | ||
displayRequestDuration: true, | ||
filter: true | ||
}); | ||
fetch('${url}') | ||
.then(res => res.json()) | ||
.then(spec => { | ||
spec.info['title'] = "${title}"; | ||
spec.info['description'] = "${description}"; | ||
window.ui = SwaggerUIBundle({ | ||
spec, | ||
dom_id: '#swagger-ui', | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
layout: 'StandaloneLayout', | ||
deepLinking: true, | ||
displayOperationId: true, | ||
displayRequestDuration: true, | ||
filter: true | ||
}); | ||
}); | ||
}; | ||
@@ -77,0 +88,0 @@ </script> |
{ | ||
"name": "next-rest-framework", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Next REST Framework - write type-safe, self-documenting REST APIs in Next.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -274,7 +274,9 @@ <p align="center"> | ||
| Name | Description | | ||
| ---------- | ----------------------------------------------------------------------------------------------------------- | | ||
| `provider` | Determines whether to render the docs using Redoc (`redoc`) or SwaggerUI `swagger-ui`. Defaults to `redoc`. | | ||
| `meta` | An object supporting `title`, `description` and `faviconUrl` properties for custom HTML meta tag values. | | ||
| `logoUrl` | A URL for a custom logo rendered in the docs. | | ||
| Name | Description | | ||
| ------------- | ----------------------------------------------------------------------------------------------------------- | | ||
| `provider` | Determines whether to render the docs using Redoc (`redoc`) or SwaggerUI `swagger-ui`. Defaults to `redoc`. | | ||
| `title` | Custom title, used for the visible title and HTML title. | | ||
| `description` | Custom description, used for the visible description and HTML meta description. | | ||
| `faviconUrl` | Custom HTML meta favicon URL. | | ||
| `logoUrl` | A URL for a custom logo. | | ||
@@ -281,0 +283,0 @@ ### [Route handler options](#route-handler-options) |
Sorry, the diff of this file is not supported yet
143186
0.43%1216
0.5%340
0.59%