I try to generate Java (Spring) code for the following openapi 3.1.0 specification using the openapi gradle plugin version 6.2.1
openapi: 3.1.0
info:
title: My-API
version: 0.0.1
paths:
/module:
get:
operationId: listModules
summary: get modules
tags:
- Modules
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Module'
components:
schemas:
Module:
type: object
description: A module
properties:
id:
type: string
format: uuid
metaData:
type: object
additionalProperties:
type: string
The type Module should have a simple id and a map from String to String. Using additionalProperties is the way to define maps according to the official openapi specification https://spec.openapis.org/oas/v3.1.0#parameter-object-examples
However, it fails with the follwing Exception:
java.lang.IllegalArgumentException: Cannot deserialize value of type java.lang.Boolean from Object value (token JsonToken.START_OBJECT)
at [Source: UNKNOWN; byte offset: #UNKNOWN]
It seems, additionalProperties expects to be a boolean, and indeed, if I change the line to
additionalProperties: true
the code generation succeeds and generates a Map<String, Object>. However, I would like to specify the value type. In fact, I don't want simple string values but a more complex types using
additionalProperties:
$ref: '#components/schemas/MetaDataItem'
which fails with the same exception. What is wrong here?
additionalPropertiesusage examples are perfectly valid. Open an issue at github.com/OpenAPITools/openapi-generator/issues, or check if there's an existing issue.additionalPropertiesbut not exactly this issue. That's why I thought I am doing wrong somehow.