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
  • Issues
  • #7575
Closed
Open
Issue created Oct 02, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] multipart/form-data parameters can conflict with other parameters

Created by: alexrashed

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?
Description

When using the content type "multipart/form-data", the form parameters are not encapsulated in a generated model interface - as it is for all other content types - but they are added to the list of parameters. However, their parameter names are not being checked if they may collide with an existing parameter. This allows form parameters to conflict with other parameters (like path, query, header, or cookie params).

openapi-generator version

4.3.1 + master

OpenAPI declaration file content or url

Gist containing a MWE spec

Generation Details

I am facing this issue with the following arguments (but it should affect most or all languages):

generatorName: typescript-angular
outputDir: generated
inputSpec: input/openapi-generator-form-param-issue.json
additionalProperties:
  ngVersion: 10.0.0
  useSingleRequestParameter: true
Steps to reproduce

Run the generator with the provided OpenAPI spec file:

java -jar .\openapi-generator-cli.jar generate --config .\config.yaml

The resulting TypeScript code does not compile (since it defines the duplicated parameter as a variable twice).

Actual output:
...
export interface FormParamPocUpdateRequestParams {
    id: number;
    id?: number;
}
...
public formParamPocUpdate(requestParameters: FormParamPocUpdateRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined}): Observable<any> {
        const id = requestParameters.id;
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling formParamPocUpdate.');
        }
        const id = requestParameters.id;
        ...
Expected output:
...
export interface FormParamPocUpdateRequestParams {
    id: number;
    id2?: number;
}
...
public formParamPocUpdate(requestParameters: FormParamPocUpdateRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined}): Observable<any> {
        const id = requestParameters.id;
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling formParamPocUpdate.');
        }
        const id2 = requestParameters.id2;
        ...
Suggest a fix

This code section is missing the check if the parameter is unique (as it is done a few lines above).

PR

I'm on to create a PR for the fix.

Assignee
Assign to
Time tracking