Skip to content

Commit

Permalink
feat: add validatorUrl to swagger options to disable validator
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Jul 6, 2020
1 parent 9237274 commit be0820e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ swaggerOptions: { // passed to SwaggerUi()
defaultModelRendering: 'schema',
showRequestHeaders: false,
swaggerVersion: 'x.x.x' // read from package.json,
validatorUrl: null, // disable swagger-ui validator
},
routePrefix: '/docs', // route where the view is returned
specPrefix: '/docs/spec', // route where the spec is returned
Expand Down
23 changes: 12 additions & 11 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import { sync as readPkgUpSync } from 'read-pkg-up';
import { Context, Middleware, Next } from 'koa';

export interface SwaggerOptions {
[key: string]: string | boolean | string[] | Record<string, unknown>;
dom_id: string;
url: string;
supportedSubmitMethods: string[];
docExpansion: string;
jsonEditor: boolean;
defaultModelRendering: string;
showRequestHeaders: boolean;
layout: string;
spec: Record<string, unknown>;
[key: string]: string | boolean | string[] | Record<string, unknown> | null | undefined;
dom_id?: string;
url?: string;
supportedSubmitMethods?: string[];
docExpansion?: string;
jsonEditor?: boolean;
defaultModelRendering?: string;
showRequestHeaders?: boolean;
layout?: string;
spec?: Record<string, unknown>;
validatorUrl?: string | null;
}

export interface KoaSwaggerUiOptions {
title: string;
oauthOptions: boolean | any;
swaggerOptions: Partial<SwaggerOptions>;
swaggerOptions: SwaggerOptions;
swaggerVersion: string;
routePrefix: string | false;
specPrefix: string;
Expand Down
5 changes: 4 additions & 1 deletion test/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const router = new KoaRouter();

app.use(koaSwagger({
exposeSpec: true,
swaggerOptions: { spec: {} },
swaggerOptions: {
spec: {},
validatorUrl: null,
},
}));

export default app;
Expand Down

0 comments on commit be0820e

Please sign in to comment.