rametta / rapini

:leafy_green: OpenAPI to React Query (or SWR) & Axios
Apache License 2.0
152 stars 18 forks source link

Anyof doesn't generate correct response #21

Closed karthikr-vti closed 1 year ago

karthikr-vti commented 1 year ago

For example following openapi spec would generate results with any instead of ModeA | ModeB for react-query v4

{"openapi":"3.0.2","info":{"title":"Test","version":"0.1.0"},"paths":{"/":{"get":{"summary":"Read Root","operationId":"read_root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Read Root Get","anyOf":[{"$ref":"#/components/schemas/ModeA"},{"$ref":"#/components/schemas/ModeB"}]}}}}}}}},"components":{"schemas":{"ModeA":{"title":"ModeA","required":["val"],"type":"object","properties":{"val":{"title":"Val","type":"number"}}},"ModeB":{"title":"ModeB","required":["config"],"type":"object","properties":{"config":{"title":"Config","type":"string"}}}}}}

Generated client (truncated): function makeRequests(axios: AxiosInstance, config?: AxiosConfig) { return { readRootGet: () => axios.request<**any**>({ method: "get", url:/ }).then(res => res.data) } as const; }

rametta commented 1 year ago

Thanks for the example file, I will look into this

rametta commented 1 year ago

@karthikr-vti This should be fixed now in version 2.3.0