Skip to content

[JAVA] etc.: generated code is incorrect for untyped schemas #6896

@gibson042

Description

@gibson042
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions