Repository navigation
Open
Open
Copy link
Labels
openapiOpenAPI and route meta
Description
Describe the feature
Context
In addition to the response code "200" and description "OK" in the OpenAPI Specification I would love to see the return types of a handler as properties as well. I've included an example below.
Notes
- For now, the OpenAPI Specification is available with an experimental config for now.
- The OpenAPI specification is available on http://localhost:3000/_nitro/openapi.json
Documentation
Technical details
The (hardcoded for now) commented out lines are what I like to see implemented:
function getPaths(): PathsObject {
const paths: PathsObject = {};
for (const h of handlersMeta) {
const { route, parameters } = normalizeRoute(h.route);
const tags = defaultTags(h.route);
const method = (h.method || "get").toLowerCase();
const item: PathItemObject = {
[method]: <OperationObject>{
tags,
parameters,
responses: {
200: {
description: "OK",
// content: {
// "application/json": {
// schema: {
// properties: {
// success: {
// type: "boolean",
// },
// },
// },
// },
// },
},
},
},
};
if (paths[route] === undefined) {
paths[route] = item;
} else {
Object.assign(paths[route], item);
}
}
return paths;
}This results in an addition to Swagger with an Example Value as well:

http://localhost:3000/_nitro/swagger
Acceptance criteria
- The properties, return object of an eventHandler should be included and displayed in:
- The OpenAPI Specification
- The Swagger OpenAPI Specification
Additional information
- Would you be willing to help implement this feature?
Reacted by Tobias Lebeitsuk, mola1129 and Markus Pöschl
Activity