{
@jsonaschema("openapi")
@openapi({
openapi: "3.0.0",
info: {
title: "Sample Api",
describe: "Optional",
version: "0.1.9"
},
servers: [
{
url: "http://localhost:3000"
}
],
security: [
{
jwt: []
}
],
components: {
securitySchemes: {
jwt: {
type: "http",
scheme: "bearer",
bearerFormat: "JWT"
}
}
}
})
endpoint1: { @endpoint({summary:"full spec"})
route: "POST /a/{}/c/{}",
req: {
params: {
b: "a",
d: 3
},
headers: {
'X-App-Key': 'Bearer Axxx...' @describe("x header")
},
query: {
kind: 'q' @optional
},
body: { @describe("default content-type application/json")
null: null,
bool: false,
integer: 3, @optional
float: 4.3,
array1: [ @describe("a simple array")
'3'
],
object1: { @def("object1")
a: 3,
b: 4
},
objectarray: [ @schema({maxItems:3})
{
a: 3
}
],
time: '2018-11-13T20:20:39Z' @schema({format:"date-time"})
}
},
res: {
200: { @describe("success response")
bool: false,
integer: 3,
float: 4.3,
array1: [
'3'
],
object1: {
a: 3,
b: 4
},
object2: { @ref("object1")
}
},
400: {
code: "ErrNoModel",
message: "no model"
}
}
},
endpoint2: { @endpoint({summary:"no req and res"})
route: "GET /endpoint2"
},
endpoint3: { @endpoint({summary:"custom content-type"})
route: "POST /endpoint3",
req: {
body: "" @contentType("applicaton/xml")
},
res: {
200: "" @contentType("applicaton/xml")
}
},
endpoint4: { @endpoint({summary:"custom response header"})
route: "GET /endpoint4",
res: {
200: { @withHeader
headers: {
'X-RateLimit': 10
},
body: {
}
}
}
},
endpoint5: { @endpoint({summary:"operation x-*","x-swagger-router-controller":"OrderController"})
route: "GET /endpoint6"
}
}