openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open UnleashSpirit opened this issue 3 years ago • 3 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] 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 ^^)

UnleashSpirit avatar Jan 19 '22 07:01 UnleashSpirit

I got the same issue. Some files have correct imports, some others not

david-dlc-cerezo avatar May 31 '22 07:05 david-dlc-cerezo

Same for multiple anyOf or oneOf without title image

A - is missing before the number increasing

tz1010 avatar Jun 10 '22 13:06 tz1010

Same here, missing - in imports

zdenekhatak avatar Aug 09 '22 20:08 zdenekhatak