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
  • #8003
Closed
Open
Issue created Nov 23, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][Java/Spring] additionalProperties to true breaks compilation

Created by: BorjaSalazar

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

v5.0.0-beta2 and v5.0.0-beta3 do not generate correct Java putPropertiesItem method for Map fields

openapi-generator version

v5.0.0-beta2, v5.0.0-beta3 and latest

Works ok in v5.0.0-beta

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Test
  version: '1.0.0'

paths:
  /test:
    get:
      summary: Test
      description: Example
      responses:
        200:
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/test'

components:
  schemas:
    test:
      type: object
      required:
        - field_A
        - field_B
      properties:
        field_A:
          type: string
          enum:
            - Feature
        field_B:
          type: integer
        properties:
          type: object
          properties:
            field_C:
              type: integer
          additionalProperties: true

Generation Details

cat out/java/src/main/java/org/openapitools/model/Test.java Expected


  public Test putPropertiesItem(String key, Object propertiesItem) {
    if (this.properties == null) {
      this.properties = new HashMap<>();
    }
    this.properties.put(key, propertiesItem);
    return this;
  }

vs

  public Test putPropertiesItem(String key, Object propertiesItem) {
    if (this.properties == null) {
      this.properties = ;
    }
    this.properties.put(key, propertiesItem);
    return this;
  }
Steps to reproduce
docker run --rm \                                          
    -v $PWD:/local openapitools/openapi-generator-cli:v5.0.0-beta3 generate \ 
    -i /local/test.yaml \
    -g spring \
    -o /local/out/java
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking