acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.38k stars 361 forks source link

multiple data-contracts #465

Open kulbon opened 1 year ago

kulbon commented 1 year ago

Is it possible to generate more than one data-contracts.ts file? One per each module?

whiplashwebb commented 1 year ago

@kulbon I had the same question and after digging through the source it seems the answer is no, or at least not easily. Check out createMultipleFileInfos() in https://github.com/acacode/swagger-typescript-api/blob/master/src/code-gen-process.js . You can override the template it uses to render data-contracts.ts, but there doesn't seem to be a way to split the generated code apart. I'm guessing you could use the templating to mark the start and end of a given interface and use that to split the output apart with another command, but as the file is just interfaces I'm not sure it's worth the effort.