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
  • Merge requests
  • !5085

[typescript-angular] Fix typescript model kebab-cased filenames

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/roddy/typescript-angular-kebab-naming into master Jan 23, 2020
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 4

Created by: roddy

When using "kebab-case" file names, the typescript-angular client generator would create model files with repeating dashes in the filenames, but the import statements would have single dashes. This was caused by the Inline Model Resolver naming the resolved models by concatenating the parent name to the child model name with an underscore separator; if the child model name had a leading underscore, this would cause a double underscore in the new model name. When this model name was converted to kebab case for the file name, each individual underscore was converted to a dash, resulting in a filename with repeated dashes.

To address, updated the dashize method in StringUtils to collapse multiple consecutive whitespace and/or underscores to a single dash. This shouldn't be a breaking change, but if need be the fix could easily be amended to make the collapsing part of the operation optional using a boolean parameter and an overloaded method call.

Added test cases to the StringUtils unit tests, Angular Typescript client code gen tests, and Angular Typescript model tests. Ran all of the tests in the project using mvn test; no failures. There were no changes to the petstore APIs or templates. Built the project and verified using the YML and commandline arguments from #5073 (closed) (yml included at bottom of PR).

Fixes #5073 (closed)

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11)

Verification

Sample YML for verification (make sure to set fileNaming to "kebab-case"):

openapi: 3.0.0
info:
  title: Example API
  description: An Example API
  version: "1.0"
paths:
  /hello:
    get:
      summary: Example endpoint
      operationId: get_hello
      responses:
        200:
          description: Example response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FooResponse'
components:
  schemas:
    FooResponse:
      type: object
      properties:
        _links:
          required:
            - collection
            - self
          type: object
          properties:
            collection:
              type: string
              format: uri
            self:
              type: string
              format: uri

Previous behavior would generate files ./models/foo-response.ts and ./models/foo-response--links.ts. New behavior is to generate ./models/foo-response-links.ts (other file unchanged).

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/roddy/typescript-angular-kebab-naming