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
  • #7040
Closed
Open
Issue created Jul 24, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG][typescript-fetch] Serilizer and deserializer methods should not be generated when generating only models

Created by: cervengoc

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?
Description

We'd like to use openapi-generator to generate only models, because we already have a general purpose API client implementation. So we pass the --global-property models option to the core generator.

However, the generated models in each typescript file contain serilaization helper methods. The logic in them need the imports from ../runtime, which doesn't exist in this setup, so the generated code is broken. Also, when generating only models, serialization helpers are kind of pointless as the responsibility of the http client logic is on the consumer side.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

I cannot provide a sample content at this point, but I think it's not too important in the context of this issue.

Command line used for generation
openapi-generator generate -i http://localhost:5000/swagger/v1.0/swagger.json -g typescript-fetch -o generated-sources/openapi --global-property models --additional-properties typescriptThreePlus=true
Steps to reproduce

Just include the --global-property models in the generator script.

Related issues/PRs

I've found no related issues.

Suggest a fix

I suggest handling this global option in the template and skip generating serializer/deserializer helper functions in this case, and also skip generating the related imports. So basically in this case only the typescript interface, and related interface imports should be in the generated model files in my opinion.

If anyone can point me to the right direction (source code point, retrieving global properties, etc.) I can try to put together a pull request myself.

Assignee
Assign to
Time tracking