OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Typescript] Filename/import with kebab-case

Open
#11,354 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

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)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating code with "double inline object" and fileNaming: "kebab-case" import and file name not matching

openapi-generator version

@openapitools/openapi-generator-cli
generator-cli: 5.2.0 (tried with 5.3.1 too)

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: API
  version: 1.1.0
paths:
  /messages:
    get:
      operationId: messagesGet
      responses:
        '200':
          description: List
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/Message'
                  urls:
                    type: object
                    properties:
                      rdv:
                        type: string
                        description: Url
                        format: uri
                      nouveau:
                        type: string
                        description: Url
                        format: uri
components:
  schemas:
    Message:
      type: object
      properties:
        id:
          type: string
        date:
          type: string
          format: date
Generation Details
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-angular -o generated -c openapi-conf.yaml

openapi-conf.yaml

apiModulePrefix: "Messagerie"
fileNaming: "kebab-case"
supportsES6: true
providedIn: "root"
generateAliasAsModel: true
enumPropertyNaming: "PascalCase"
modelPropertyNaming: "original"
ngVersion: "13.0.1"

openapitools.json

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.2.0",
    "repository": {
      "downloadUrl": "<custom_nexus>/maven-public/org/openapitools/openapi-generator-cli/5.2.0/openapi-generator-cli-5.2.0.jar"
    }
  }
}
Steps to reproduce
  • run the bash command
  • Check generated > model > inline-response-200.ts > import { InlineResponse200Urls } from './inline-response200-urls';
  • Check the generated name > inline-response-200-urls.ts
  • See the mismatch

image

Workaroud

Don't use kebab-case filename, no problem
(so camelCase)

If I found time, I would be happy to PR this
(and if I found where it is ^^)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with the provided OpenAPI declaration and generation command, then compare the import in model/inline-response-200.ts with the generated model/inline-response-200-urls.ts. Trace the typescript-angular generator's filename and import handling for nested inline objects with fileNaming set to kebab-case; done means the import matches the generated filename.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.