Skip to content

Commit

Permalink
feat(swagger-uri): Add Full Configuration Parameters and Update Depen…
Browse files Browse the repository at this point in the history
…dencies (#618)

* chore(swagger-ui): update swagger-ui-dist types

* feat(swagger-ui): add swagger-ui parameters

* chore(swagger-ui): fix typeerror

add url parameter

* chore(swagger-ui): refactor test case

* chore: add versioning doc

* chore(swagger-ui): remove useUnsafeMarkdown

* chore(swagger-ui): add requestSnippetsEnabled

* chore(swagger-ui): syntaxHighlight: boolean

* chore(swagger-ui): fix propertykey

* chore(swagger-ui): format code

* chore(swagger-ui): add string function property commented
  • Loading branch information
naporin0624 authored Jul 10, 2024
1 parent 61cd9b6 commit 47be5c6
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 171 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-flies-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/swagger-ui': minor
---

Add Full Configuration Parameters and Update Dependencies for Swagger UI
2 changes: 1 addition & 1 deletion packages/swagger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"hono": "*"
},
"devDependencies": {
"@types/swagger-ui-dist": "^3.30.3",
"@types/swagger-ui-dist": "^3.30.5",
"hono": "^3.11.7",
"publint": "^0.2.2",
"tsup": "^7.2.0",
Expand Down
61 changes: 60 additions & 1 deletion packages/swagger-ui/src/swagger/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,60 @@ export type DistSwaggerUIOptions = {
layout?: SwaggerConfigs['layout']
docExpansion?: SwaggerConfigs['docExpansion']
maxDisplayedTags?: SwaggerConfigs['maxDisplayedTags']
/**
* accepts function as a string.
*
* @example (a, b) => a.path.localeCompare(b.path)
*/
operationsSorter?: string
/**
* accepts function as a string.
*
* @example (req) => req
*/
requestInterceptor?: string
/**
* accepts function as a string.
*
* @example (res) => res
*/
responseInterceptor?: string
persistAuthorization?: boolean
defaultModelsExpandDepth?: number
defaultModelExpandDepth?: number
defaultModelRendering?: "example" | "model" | undefined
defaultModelRendering?: 'example' | 'model' | undefined
displayRequestDuration?: boolean
filter?: boolean | string
showExtensions?: boolean
showCommonExtensions?: boolean
queryConfigEnabled?: boolean
displayOperationId?: boolean
/**
* accepts function as a string.
* swagger-ui accepts alpha in the tagsSorter, but this middleware does not support it.
*
* @example (a, b) => a.name.localeCompare(b.name)
*/
tagsSorter?: string
/**
* accepts function as a string.
* @example () => { console.log('Swagger UI Loaded'); }
*/
onComplete?: string
syntaxHighlight?: boolean | { activated: boolean; theme: string[] }
tryItOutEnabled?: boolean
requestSnippetsEnabled?: boolean
requestSnippets?: object
oauth2RedirectUrl?: string
showMutabledRequest?: boolean
request?: {
curlOptions?: string[]
}
supportedSubmitMethods?: string[]
validatorUrl?: string
withCredentials?: boolean
modelPropertyMacro?: string
parameterMacro?: string
} & RequireOne<{
url?: SwaggerConfigs['url']
urls?: SwaggerConfigs['urls']
Expand Down Expand Up @@ -59,6 +102,22 @@ const RENDER_TYPE_MAP = {
filter: RENDER_TYPE.RAW,
showExtensions: RENDER_TYPE.RAW,
showCommonExtensions: RENDER_TYPE.RAW,
queryConfigEnabled: RENDER_TYPE.RAW,
displayOperationId: RENDER_TYPE.RAW,
tagsSorter: RENDER_TYPE.RAW,
onComplete: RENDER_TYPE.RAW,
syntaxHighlight: RENDER_TYPE.JSON_STRING,
tryItOutEnabled: RENDER_TYPE.RAW,
requestSnippetsEnabled: RENDER_TYPE.RAW,
requestSnippets: RENDER_TYPE.JSON_STRING,
oauth2RedirectUrl: RENDER_TYPE.STRING,
showMutabledRequest: RENDER_TYPE.RAW,
request: RENDER_TYPE.JSON_STRING,
supportedSubmitMethods: RENDER_TYPE.JSON_STRING,
validatorUrl: RENDER_TYPE.STRING,
withCredentials: RENDER_TYPE.RAW,
modelPropertyMacro: RENDER_TYPE.RAW,
parameterMacro: RENDER_TYPE.RAW,
} as const satisfies Record<
keyof DistSwaggerUIOptions,
(typeof RENDER_TYPE)[keyof typeof RENDER_TYPE]
Expand Down
Loading

0 comments on commit 47be5c6

Please sign in to comment.