-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Description
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: [email protected]
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: stringCommand 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
- typescript-angular: Make the api suffix configurable #234 and typescript-angular: Feature/model suffix #418
- [angular-typescript] Bug generating model with suffix #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!