Open VonLatvala opened 1 year ago
In https://github.com/aaronpowell/azure-functions-nodejs-openapi/blob/main/src/openAPIv3.ts#L29 (generateOpenApiSpec), the whole context.res is getting overwritten with an object containing only the response body. This makes it impossible to prepare custom response headers (for example CORS) by wrapping the function in another higher level function.
context.res
I propose that generateOpenApiSpec surgically inserts the response body instead of nuking the whole response object.
generateOpenApiSpec
Another solution could be to accept an option which sets CORS headers as requested, but this is less flexible.
It'd probably be better if the line was context.res = { ...context.res, body }, so it added the body to the existing one.
context.res = { ...context.res, body }
Feel free to submit a PR, otherwise I'll get to it when I have some time.
In https://github.com/aaronpowell/azure-functions-nodejs-openapi/blob/main/src/openAPIv3.ts#L29 (generateOpenApiSpec), the whole
context.res
is getting overwritten with an object containing only the response body. This makes it impossible to prepare custom response headers (for example CORS) by wrapping the function in another higher level function.I propose that
generateOpenApiSpec
surgically inserts the response body instead of nuking the whole response object.Another solution could be to accept an option which sets CORS headers as requested, but this is less flexible.