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

[BUG] [typescript-node] Generating only models generates invalid TS

Created by: sarumont

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

When providing --global-property models to generate only models, the resultant TypeScript references ../api for importing RequestFile.

openapi-generator version
4.3.1

Not a regression that I know of.

OpenAPI declaration file content or url

Any valid OpenAPI file containing models will reproduce this.

openapi: 3.0.2
info:
  version: 0.3.0
  description: null
  title: '@devsupply/core-types-typedefs'
paths:
  /foo:
    get:
      tags:
        - foo
      operationId: getFoo
      responses:
        "204":
          description: Foo
components:
  schemas:
    CloudProvider:
      type: string
      enum:
        - AWS
        - AZURE
        - GOOGLE
      x-enum-descriptions:
        - Amazon AWS
        - Microsoft Azure
        - Google Cloud Platform
Generation Details
npx openapi-generator generate 
    -g typescript-node 
    --global-property models 
    -i ./example.yml -o gen/
Steps to reproduce

Generate code as above. Attempt to build via TypeScript:

npx tsc gen/model/cloudProvider.ts

Results in:

13 import { RequestFile } from '../api';
                               ~~~~~~~~


Found 1 error.
Suggest a fix

Suggest moving the RequestFile definition into models.ts and also generating this file when --global-property models is provided. Will submit a PR with this fix...

Related Issue: #7040 (closed) (it should be noted that moving the RequestFile definition will not work until #7040 (closed) is addressed, as the validators import things from request)

Assignee
Assign to
Time tracking