Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error for parameter with explode #45

Closed
anantoghosh opened this issue May 21, 2020 · 3 comments
Closed

Type error for parameter with explode #45

anantoghosh opened this issue May 21, 2020 · 3 comments
Assignees

Comments

@anantoghosh
Copy link

Getting type error in addQueryParams
using typescript 3.9

this.request<any, any>(`/something/${this.addQueryParams(query)}`, "GET", params, null)
Argument of type '{ params?: QueryParams | undefined; } | undefined' is not assignable to parameter of type 'Record<string, string | number | boolean | string[] | number[] | undefined> | undefined'.
  Type '{ params?: QueryParams | undefined; }' is not assignable to type 'Record<string, string | number | boolean | string[] | number[] | undefined>'.
    Property 'params' is incompatible with index signature.
      Type 'QueryParams | undefined' is not assignable to type 'string | number | boolean | string[] | number[] | undefined'.
        Type 'QueryParams' is not assignable to type 'string | number | boolean | string[] | number[] | undefined'.
          Type 'QueryParams' is missing the following properties from type 'number[]': length, pop, push, concat, and 28 more.

where QueryParams is generated as

export interface QueryParams {
  /**
   * Page number
   */
  page?: number | null;

  /**
   * Page size
   */
  "page-size"?: number | null;
}
openapi: 3.0.1
info:
  title: API
  description: Documentation
  version: "0.1"
paths:
  /something/:
    get:
      operationId: gets
      parameters:
      - name: params
        in: query
        required: false
        explode: true
        schema:
          $ref: '#/components/schemas/QueryParams'

components:
  schemas:
    QueryParams:
      type: object
      properties:
        page:
          minimum: 0
          type: integer
          description: Page number
          format: int32
          nullable: true
        page-size:
          minimum: 0
          type: integer
          description: Page size
          format: int32
          nullable: true

With explode set the query url would have ?page=0&page-size=0
Any help would be appreciated.

@js2me
Copy link
Member

js2me commented May 21, 2020

Hello! Thanks for your issue!
Currently, swagger-typescript-api don't have support explode property but I think I'll add this support today or at next day hopefully

@js2me js2me self-assigned this May 21, 2020
@js2me js2me mentioned this issue May 21, 2020
@js2me
Copy link
Member

js2me commented May 21, 2020

Release 1.80 should partially fix that issue (type errors + generating query string with nested objects)

About fields minimum, maximum:
Currently Api class structure is not able to somehow include that information into data.
And I imagine a bit what needs to do with result Api class structure it isn't worth it :)

Hope new version will help with this problem :)

@js2me js2me closed this as completed May 21, 2020
@anantoghosh
Copy link
Author

@js2me Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants