swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Question about Axios template

Open mxmory opened this issue 3 years ago • 0 comments

Generated axios request template: Screenshot 2022-09-07 at 23 28 24

I have 2 different schemas for request and response:

Request schema: (id and color are optional to create this entity)

StageModel {
  id?: number;
  name: string;
  color?: string;
  ...
  ...
}

Response schema: (no optional fields because I'm sure they will be presented in response and don't want typescript to complain like 'id' is possibly undefined in future use in my react components)

StageModelResponse {
  id: number;
  name: string;
  color: string;
  ...
  ...
}

So the question is: can I generate different types and put them to axios request and response respectively? Or maybe I'm doing this all wrong and this can be achieved in more correct/elegant way? Someone help please! Thanks in advance 🙏

mxmory avatar Sep 07 '22 20:09 mxmory