Skip to content

Allow types to be added to query parameter definitions #261

Open
@johnthagen

Description

@johnthagen

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

It is currently not possible to provide a type for a query parameter.

# This should be documented in the OpenAPI as an integer, but cannot express that.
limit_query_param = ns.param('limit', 'Maximum number of results to be returned.')

Screen Shot 2020-12-16 at 8 30 52 AM

When client code is generated, for example for TypeScript, string types are using instead of number which makes the code less self-descriptive and error prone. It also requires extra type conversions, e.g. String(limit).

 /**
   *
   * @param {string} [limit] Maximum number of results to be returned.
   * @param {string} [xFields] An optional fields mask
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiApi
   */
  public getTodoList(
    limit?: string,  # This should be integer
    options?: any

Describe the solution you'd like

Be able to express the type of a query parameter and have that propagate to the OpenAPI schema.

# type defaults to string for backwards compatibilty
limit_query_param = ns.param('limit', 'Maximum number of results to be returned.', type=SchemaTypes.integer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions