[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