Skip to content

13.0.0: --route-types option is ignored #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aki202 opened this issue Aug 13, 2023 · 1 comment
Open

13.0.0: --route-types option is ignored #585

aki202 opened this issue Aug 13, 2023 · 1 comment

Comments

@aki202
Copy link

aki202 commented Aug 13, 2023

Summary

It appears that swagger-typescript-api started ignoring the "--route-types" option from version 13.0.0.

Version

  • swagger-typescript-api: 13.0.0
  • Node.js: 18.16.0

Reproduce

I created a sample project to reproduce this behavior.

https://codesandbox.io/p/sandbox/sleepy-golick-5zt4wz?file=%2Fpackage.json%3A25%2C32

  1. Run npx sta -p oas.yaml --no-client --route-types in terminal.
  2. The generated ts file Api.ts has no routes typings.

It seems internal variable config.generateRouteTypes cannot be set to true.

@Jackman3005
Copy link

Nice find, this unfortunately stops us from using v13... We are using this feature to add request and response types to our express route handlers. It has been working very well for us for quite some time. Although, it would be nice if there were a way for us to reference the whole route as an interface and then dive into the query, body, response, etc from there. B/c we cannot reference the whole route we have to navigate the namespace four times for all our endpoints. See below:

export const postLoginRoute: ApiEndpoint<
  apitypes.Login.LoginCreate.RequestParams,
  apitypes.Login.LoginCreate.RequestBody,
  apitypes.Login.LoginCreate.RequestQuery,
  apitypes.Login.LoginCreate.ResponseBody
> = async (req, res) => {
  const body = req.body // this is correctly typed based on the OpenAPI spec.
  ...
  res.send({...}); // the parameter to send is conveniently validated against the generated response type
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants