swagger-api / swagger-api/swagger-codegen
[JAVA] etc.: generated code is incorrect for untyped schemas
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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
swagger: '2.0'
info:
title: 'map of arbitrary values'
version: '1'
produces: ["application/json"]
paths:
/mapOfAnything:
get:
operationId: mapOfAnything
responses:
default:
schema:
description: 'map of arbitrary values'
type: object
additionalProperties:
description: Any JSON type
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 of Map<String, Object>, despite describing a map.
Related issues/PRs
None found.
Suggest a fix/enhancement
Treat untyped schemas as generically as possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied swagger.yaml and reproduce the issue using run-in-docker.sh generate -i swagger.yaml -l java. Inspect the Java generation path for the response schema and verify that the untyped additionalProperties case is represented as Map<String, Object> rather than Object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100