-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
I migrated import swagger from "@elysiajs/swagger"; to import openapi from "@elysiajs/openapi";, because swagger not suport mapJsonSchema and I preferer zod to validate schemas, but i have a problem.
With openapi, it is ignoring the operationIn in rotes.
The route example:
.delete(
"/:id",
async ({ params, user, set }) => {
try {
await prisma.payment.update({
where: { id: params.id },
data: {
deletedAt: new Date(),
deletedBy: user.id,
},
});
set.status = 204;
} catch {
set.status = 404;
return { error: "Payment not found" };
}
},
{
auth: true,
params: t.Object({
id: t.String({ format: "uuid" }),
eventId: t.String({ format: "uuid" }),
}),
response: {
204: t.Void(),
404: t.Object({
error: t.String({
description: "Error message",
}),
}),
},
detail: {
summary: "Soft delete a payment by ID",
operationId: "deleteEventPaymentById",
},
schema: {
detail: {
operationId: "deleteEventPaymentById",
},
},
}
);.use(
openapi({
path: "/docs",
documentation: {
info: {
title: "Vortex API",
version: "1.0.0",
},
},
mapJsonSchema: {
zod: z.toJSONSchema,
},
})
)
.use(
swagger({
path: "/docs2",
documentation: {
info: {
title: "Vortex API",
version: "1.0.0",
},
// components: await OpenAPI.components,
// paths: await OpenAPI.getPaths(),
},
})
)result with swagger:
{
"delete":{
"parameters":[
{
"schema":{
"type":"string",
"format":"uuid"
},
"in":"path",
"name":"id",
"required":true
},
{
"schema":{
"type":"string",
"format":"uuid"
},
"in":"path",
"name":"eventId",
"required":true
}
],
"responses":{
"204":{
},
"404":{
"content":{
"application/json":{
"schema":{
"type":"object",
"properties":{
"error":{
"description":"Error message",
"type":"string"
}
},
"required":[
"error"
]
}
},
"multipart/form-data":{
"schema":{
"type":"object",
"properties":{
"error":{
"description":"Error message",
"type":"string"
}
},
"required":[
"error"
]
}
},
"text/plain":{
"schema":{
"type":"object",
"properties":{
"error":{
"description":"Error message",
"type":"string"
}
},
"required":[
"error"
]
}
}
}
}
},
"operationId":"deleteEventPaymentById",
"tags":[
"Event - Payments"
],
"summary":"Soft delete a payment by ID"
}}but with openapi
{
"delete":{
"tags":[
"Event - Payments"
],
"summary":"Soft delete a payment by ID",
"operationId":"deleteEventByEventIdPaymentsById",
"parameters":[
{
"name":"id",
"in":"path",
"required":true,
"schema":{
"format":"uuid",
"type":"string"
}
},
{
"name":"eventId",
"in":"path",
"required":true,
"schema":{
"format":"uuid",
"type":"string"
}
}
],
"responses":{
"204":{
"description":"Response for status 204",
"content":{
"type":"void"
}
},
"404":{
"description":"Response for status 404",
"content":{
"application/json":{
"schema":{
"type":"object",
"properties":{
"error":{
"description":"Error message",
"type":"string"
}
},
"required":[
"error"
]
}
}
}
}
}
}
},What can I do to make it use the operationId?
Metadata
Metadata
Assignees
Labels
No labels