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
  • !4569

Use model as body param for generateAliasAsModel

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/bodograumann/body-parameter-as-alias into master Nov 21, 2019
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 9

Created by: bodograumann

Fixes #3602 (closed):

When enabling generateAliasAsModel, schemes which are aliases for maps or arrays are generated as models by all templates. Those models where previously not imported and used for the relevant body parameters though.

I have not added any tests, but for my own use case the change works and the one sample where the generateAliasAsModel option is activated also shows the change in effect.

Example

Considering the following OpenAPI definition.

openapi: 3.0.2
info:
    title: Map Alias Example
    version: 0.1.0
    description: Use a data scheme which is only an alias for a map.
paths:
    '/users/{userId}/roles':
        patch:
            requestBody:
                content:
                    application/json:
                        schema:
                            $ref: '#/components/schemas/UserRoleUpdateRequest'
                required: true
            parameters:
                -
                    name: userId
                    schema:
                        type: string
                    in: path
                    required: true
            responses:
                '200':
                    description: Update successfull.
            operationId: updateUserRoles
components:
    schemas:
        UserRoleUpdateRequest:
            type: object
            additionalProperties:
                type: boolean
            example:
                admin: true
                user: false

Usually it would generate typescript-inversify code:

  public updateUserRoles(
    userId: string,
    requestBody: { [key: string]: boolean },
    observe?: "body",
    headers?: Headers
  ): Promise<any>;

Instead it should generate:

  public updateUserRoles(
    userId: string,
    userRoleUpdateRequest: UserRoleUpdateRequest,
    observe?: "body",
    headers?: Headers
  ): Promise<any>;
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/bodograumann/body-parameter-as-alias