express-openapi: fix argument object of initialize method

This commit is contained in:
TANAKA Koichi
2016-02-19 12:35:50 +09:00
parent 9e677ad06b
commit 24e2e1fca3
2 changed files with 42 additions and 3 deletions

View File

@@ -10,7 +10,14 @@ var api:openapi.InitializedApi;
api = openapi.initialize({
apiDoc: require('./api-doc.js'),
app: app,
routes: './api-routes'
routes: './api-routes',
docPath: '/doc',
exposeApiDocs: true,
validateApiDoc: true,
errorTransformer: (openapiError, jsonschemaError) => {},
customFormats: {
myFormat: input => { return true; },
}
});
app.listen(3000);

View File

@@ -248,9 +248,14 @@ declare module "express-openapi" {
}
export interface Args {
apiDoc: OpenApi.ApiDefinition,
app: express.Application,
apiDoc: OpenApi.ApiDefinition
app: express.Application
routes: string
docPath: string
errorTransformer(openapiError: OpenapiError, jsonschemaError: JsonschemaError): any
exposeApiDocs: boolean
validateApiDoc: boolean
customFormats: CustomFormats
}
export interface OperationFunction extends express.RequestHandler {
@@ -275,6 +280,33 @@ declare module "express-openapi" {
head?: Operation;
}
export interface OpenapiError {
errorCode: string
location: string
message: string
path: string
}
export interface CustomFormats {
[index: string]: CustomFormatValidator
}
// Following 2 interfaces are part of jsonschema package.
interface JsonschemaError {
property: string
message: string
schema: string|IJsonSchema
instance: any
name: string
argument: any
stack: string
toString(): string
}
interface CustomFormatValidator {
(input: any): boolean
}
interface IJsonSchema {
id?: string
$schema?: string