Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Generate proper API description for Map types using "additionalProperties" #142

@clementdenis

Description

@clementdenis

Both Discovery and Swagger formats support generic Map types, through the "additionalProperties" field in JsonSchema. This is also supported by the Java API client generator used by Cloud Endpoints.

However, all Map input and output types are currently handled by Cloud Endpoints as "JsonMap", which prevent proper autocomplete in API explorer / Swagger UI, and generate API clients with no typing at for Maps.

This branch in our fork implements Map support through additionalProperties.

Before creating a PR, I'd like to validate a few things:

  • As the new Map handling is not backward-compatible, it is enabled with a flag
    => I'm not sure about the naming of the flag (endpoints.supportGenericMapTypes), and the way it is enabled (both with env variables and system properties). Could you advise us on that?
  • The cloud-based API client lib generator (CloudClientLibGenerator) does not seem to support array-typed Map values, it generates invalid Java code with blank field types, while the API explorer supports it just fine
    => by default, array Map values still use JsonMap, and a specific flag was added to enable full support, allowing to have different configuration for client lib generation and API serving. Does it make sense to you?
  • Another flag can also be used to log the invalid map type key or value types.
    => Do you think these warning could be enabled by default? And considering Map types are now introspected fully, should the Schema generation fail when encountering key types not serializable to String?

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