Closed MartinN3 closed 11 months ago
I just ran into the same issue. Is there any info?
sorry for the late response, I've been focusing on maintaining another open source library (Panda CSS), so I haven't been using this lib for a while, feel free to send a PR 🙏
Thanks for acknowledge
@astahmer I believe the patchfile below fixes this issue. I have a whole branch with this if you give me a way to make a PR.
diff --git a/packages/typed-openapi/src/generator.ts b/packages/typed-openapi/src/generator.ts
index 79ce224..e51b149 100644
--- a/packages/typed-openapi/src/generator.ts
+++ b/packages/typed-openapi/src/generator.ts
@@ -143,6 +143,7 @@ const generateEndpointSchemaList = (ctx: GeneratorContext) => {
${parameters.query ? `query: ${parameterObjectToString(parameters.query)},` : ""}
${parameters.path ? `path: ${parameterObjectToString(parameters.path)},` : ""}
${parameters.header ? `header: ${parameterObjectToString(parameters.header)},` : ""}
+ ${parameters.body ? `body: ${parameterObjectToString(parameters.body)},` : ""}
}`
: "parameters: never,"
}
diff --git a/packages/typed-openapi/src/map-openapi-endpoints.ts b/packages/typed-openapi/src/map-openapi-endpoints.ts
index dc852a5..a7107fb 100644
--- a/packages/typed-openapi/src/map-openapi-endpoints.ts
+++ b/packages/typed-openapi/src/map-openapi-endpoints.ts
@@ -72,6 +72,7 @@ export const mapOpenApiEndpoints = (doc: OpenAPIObject) => {
// Body
if (operation.requestBody) {
+ endpoint.meta.hasParameters = true;
const requestBody = refs.unwrap(operation.requestBody ?? {});
const content = requestBody.content;
const matchingMediaType = Object.keys(content).find(isAllowedParamMediaTypes);
@@ -154,7 +155,7 @@ type MutationMethod = "post" | "put" | "patch" | "delete";
type Method = "get" | "head" | "options" | MutationMethod;
export type EndpointParameters = {
- body?: Box;
+ body?: Box<BoxRef>;
query?: Box<BoxRef> | Record<string, AnyBox>;
header?: Box<BoxRef> | Record<string, AnyBox>;
path?: Box<BoxRef> | Record<string, AnyBox>;
awesome !
if you give me a way to make a PR.
what do you mean ? to contribute you can fork the repo, then :
pnpm i
// make your changes then
pnpm build
// add your test then
pnpm test
@astahmer cool, didn't know that forking was necessary, so wasn't clear, but will do
I think this fix introduced a problem. Body type names are not prefixed by namespace Schemas.
which leads to typescript errors.
would you like to work on the fix ?
I'll have a Look :-)
this was fixed recently ! https://github.com/astahmer/typed-openapi/pull/16
In your example you have
which means body can be specified, therefore
should be
is that a case? Thanks.