Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3349
Closed
Open
Issue created Jul 12, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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(() => {
   });
});
Assignee
Assign to
Time tracking