openapi-generator-plus-generators icon indicating copy to clipboard operation
openapi-generator-plus-generators copied to clipboard

Method with several status codes generates only one return

Open psamusev opened this issue 3 years ago • 7 comments

I have method that describe DELETE operation. Responses array of swagger may look like

      responses:
        '200':
          description: Removed response with body
          content:
            application/json:
              schema:
                type: object
        '204':
          description: Removed response
        '404':
          description: Time record is not exist
          content:
            application/json:
              schema:
                type: object

When I generates it with @openapi-generator-plus/[email protected], I have only one return and the rest are throws

						if (mimeType === 'application/json') {
							return response.json() as any;
						}
						throw response;
					}
					if (response.status === 204) {
						throw response;
					}
					if (response.status === 404) {
						if (mimeType === 'application/json') {
							throw response;
						}
						throw response;
					}

Expected behavior: Following the standart of status code, as for me, only 500th and 400th error codes should throw response object - the res should just return it

psamusev avatar Nov 12 '21 12:11 psamusev