Skip to content

Optionally generate methods for obtaining map keys and list indexes #4

@andylowry

Description

@andylowry

In the type configuration used by the generator, a 'map' type is implemented as a map of strings to values, and a collection type is implemented as a collection of values. The overlay adapter method getPathInParent can be used to obtain the map key or list position (though as a string, e.g. "10" not 10). But this is clumsy to code.

We should add a type configuration property like selectorName that, when present, will cause a convenience method to be defined for the object. For example, if we have selectorName: name on a map type, then the generated API for that type will include a method getName() that returns a string. Likewise, selectorName: position on a collection type will give rise to int getPosition().

These methods should return null if the instance does not happen to appear as a MapOverlay or ListOverlay child, and references to the instance, naturally, will reflect its non-reference occurrence (since there will only really be a single instance of the type, and its parent, if any, will be set according to where it was inlined). So e.g. in an OpenAPIv3 document, a Schema object may appear in the /components/schemas map but may also be referenced from various places in the overall model. Its name will be the name appearing in the /components/schemas map.

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