Skip to content

Support for Free-Form Query Parameters #295

Closed
benchling/openapi-python-client
#39
@bowenwr

Description

@bowenwr

Is your feature request related to a problem? Please describe.

Given an API that accepts arbitrarily-named query parameters like:

/my-endpoint/?dynamic_param1=value&dynamic_param2=value2

We'd like to be able to append arbitrary key/values to the query string search.

Given a current YAML snippet like:

    parameters:
        - in: query
          name: dynamicFields
          schema:
            type: object
            additionalProperties: true

The parameter generated is schema_field: Union[Unset, ModelNameSchemaField] = UNSET, and it's also sent as the parameter named schema_field instead of using the arbitrary keys.

Describe the solution you'd like

Generate the parameter above with additionalProperties as schema_field: Union[Unset, None, Dict[str, Any]] = UNSET. When schema_field is a dict, it will then send values for all keys in the query parameters instead of as schema_field.

If multiple parameters are defined having additionalProperties, it will treat all of them as arbitrary keys. If two parameters were to define the same dynamically named key, we make no guarantees about which one is sent. I imagine it would be the last parameter encountered with additionalProperties. Alternatively, we could raise an exception instead of making silent assumptions about the collision.

Describe alternatives you've considered

Rather than modeling the field in Open API, allow every GET method to accept an additional_properties: Dict[str, str] parameter which would append all the keys as query parameters. The name additional_properties might need to be configurable to avoid collision with APIs using that parameter name already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions