[BUG] Typescript-fetch generator not respecting the specification
Created by: JFCote
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
There was a big refactoring in the typescript-fetch generator that was introduced with version 4.X.X. A lot of stuff has been added and it's good work. Unfortunately, there is one big problem. The new generated code is not following the specification which break every software using the previous fetch generator.
Let me explain with an example:
If you look at the test (which currently passes), you can see that the addPet
function doesn't receive a Pet
object as expected.
https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts#L19
Instead, it uses an interface called AddPetRequest
which doesn't exist at all in the spec.
https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts#L25
You can see in the spec here that it should receive a simple Pet
object.
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml#L36
openapi-generator version
Latest 4.0.3 and master
OpenAPI declaration file content or url
Using default petstore.yaml
used for the samples.
Command line used for generation
./bin/typescript-fetch-petstore-all.sh
Steps to reproduce
Just generate the code using the sh
script.
Related issues/PRs
N/A
Suggest a fix
We need to remove the Request
interface. The code should respect the spec.
For example, the test should be like this:
it('should add and delete Pet', () => {
return api.addPet(fixture).then(() => {
});
});
instead of this:
it('should add and delete Pet', () => {
return api.addPet({ body: fixture }).then(() => {
});
});