-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JAVA] etc.: generated code is incorrect for untyped schemas #6896
Comments
We have the same problem with Java CodeGen and additionalProperties without a specific type. We have a meta field in our response structure that may contain arbitrary properties. So, ideally we'd like to use something like that swagger: "2.0"
info:
version: "1.0.0"
title: "Test"
paths:
/test:
get:
description: "Test request"
responses:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/Meta"
definitions:
Meta:
description: Key value map for meta data.
type: object
additionalProperties: {} to make it explicit that there are no restrictions on the type of additional properties. With that the Meta class is of type As a hack to work around this issue, we use additionalProperties:
type: object This fixes the problem with Java CodeGen but leads to validation errors when validating our response data since most meta properties are simple types like strings and integers instead ob objects. I would be great if the pull requests from @gibson042 could get merged to fix this problem. |
Description
Generated code for schemas with no defined type is incorrect, because parsing seems to require a
type
property despite it being optional in the specification (where it defines values that can be of any type).Swagger-codegen version
2.2.3, 2.3.0-SNAPSHOT
Swagger declaration file content or url
Command line used for generation
./run-in-docker.sh generate -i swagger.yaml -l java
Steps to reproduce
Generate code from the above YAML. Observe that the response is treated as
Object
instead ofMap<String, Object>
, despite describing a map.Related issues/PRs
None found.
Suggest a fix/enhancement
Treat untyped schemas as generically as possible.
The text was updated successfully, but these errors were encountered: