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
  • #2560
Closed
Open
Issue created Apr 01, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][typescript-angular] Incorrect import path when using prefix/suffix for model names

Created by: jahow

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

When generating code for the typescript-angular language and specifying either --model-name-prefix or --model-name-suffix, the paths used for importing models are wrong (missing said prefix/suffix).

Using the spec & command given below, a model file called model/testSchema.ts is generated,:


/**
 * blah
 */
export interface TestSchemaModel { 
    description?: string;
    creationDate?: Date;
    code?: string;
}

The import for this model in api/default.service.ts is as follow:

...

import { TestSchemaModel } from '../model/testSchemaModel';

...

The path is wrong and should be ../model/testSchema (or alternatively the name of the model file is wrong).

openapi-generator version

master and 4.0.0-beta2.

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Sample API
  version: "1.0.0"
  contact:
    email: you@your-company.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

paths:
  /TestSchema/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      operationId: find
      responses:
        200:
          description: returns something
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestSchema'

components:
  schemas:

    TestSchema:
      description: blah
      allOf:
        - type: object
          properties:
            description:
              type: string
            creation_date:
                type: string
                format: 'date-time'
            code:
              type: string
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i schema.yaml -g typescript-angular -o testoutput --model-name-suffix=model
Related issues/PRs
  • https://github.com/OpenAPITools/openapi-generator/issues/234 and https://github.com/OpenAPITools/openapi-generator/pull/418
  • https://github.com/OpenAPITools/openapi-generator/issues/957
Suggest a fix

I've looked into the source code but have not yet found what would be the cause of this behaviour. Will create a PR if I ever find a fix for this on my own (if that's okay?).

Thanks a lot for this great project!

Assignee
Assign to
Time tracking