mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
express-openapi: Add definition for path item module
This commit is contained in:
@@ -13,8 +13,43 @@ api = openapi.initialize({
|
||||
routes: './api-routes'
|
||||
});
|
||||
|
||||
app.use(function (err, req, res, next) {
|
||||
res.status(err.status).json(err);
|
||||
});
|
||||
app.listen(3000);
|
||||
|
||||
app.listen(3000);
|
||||
// "./api-routes/user/{id}.ts"
|
||||
export var get: openapi.Operation = (req, res, next) => {
|
||||
};
|
||||
|
||||
export var post: openapi.Operation = [(req, res, next) => {}];
|
||||
|
||||
export var parameters = [
|
||||
{
|
||||
name: 'id',
|
||||
in: 'path',
|
||||
type: 'string'
|
||||
}
|
||||
];
|
||||
|
||||
get.apiDoc = {
|
||||
description: 'get user information',
|
||||
operationId: 'getUser',
|
||||
parameters: [
|
||||
{
|
||||
name: 'includeDetail',
|
||||
in: 'query',
|
||||
type: 'boolean'
|
||||
}
|
||||
],
|
||||
responses: {
|
||||
default: {$ref: '#/definitions/error'}
|
||||
},
|
||||
"x-some-vendor-property": {}
|
||||
};
|
||||
|
||||
post.apiDoc = {
|
||||
description: 'post to user',
|
||||
operationId: 'postToUser',
|
||||
responses: {
|
||||
default: {$ref: '#/definitions/error'}
|
||||
},
|
||||
"x-some-vendor-property": {}
|
||||
}
|
||||
Vendored
+22
@@ -251,6 +251,28 @@ declare module "express-openapi" {
|
||||
routes: string
|
||||
}
|
||||
|
||||
export interface OperationFunction extends express.RequestHandler {
|
||||
apiDoc?: OpenApi.OperationObject;
|
||||
}
|
||||
|
||||
export interface OperationHandlerArray {
|
||||
apiDoc?: OpenApi.OperationObject;
|
||||
[index: number]: express.RequestHandler;
|
||||
}
|
||||
|
||||
export type Operation = OperationFunction | OperationHandlerArray;
|
||||
|
||||
export interface PathModule {
|
||||
parameters?: OpenApi.Parameters;
|
||||
get?: Operation;
|
||||
put?: Operation;
|
||||
post?: Operation;
|
||||
delete?: Operation;
|
||||
patch?: Operation;
|
||||
options?: Operation;
|
||||
head?: Operation;
|
||||
}
|
||||
|
||||
interface IJsonSchema {
|
||||
id?: string
|
||||
$schema?: string
|
||||
|
||||
Reference in New Issue
Block a user