Skip to content

[BUG] typescript-fetch unique item array with primitives in response body is not wrapped into Set #24888

Description

@WojciechZankowski

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Unique item array with primitives in response body is not wrapped into Set and that is causing failures if someone wants to call operations available in Set class.

npm notice run npx
npm notice run tsx test-set-response.ts
Result: [ 'a', 'b', 'c' ]
Is Set: false
Is Array: true
Test failed with error: TypeError: result.has is not a function
    at run (C:\Users\wojci\IdeaProjects\openapi-generator-wza\samples\client\petstore\typescript-fetch\builds\set-type-mappings\test-set-response.ts:21:40)
Image
openapi-generator version

7.25.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: uniqueItems test spec
  version: 1.0.0
  description: >-
    Spec used to test arrays with uniqueItems across every OpenAPI location
    and item type (string, integer, number, boolean, object, array, $ref).
paths:
  /unique-primitive-response-body:
    get:
      operationId: uniquePrimitiveResponseBody
      responses:
        '200':
          $ref: '#/components/responses/UniquePrimitiveArrayResponse'
components:
  schemas:
    UniqueStringArray:
      type: array
      uniqueItems: true
      items:
        type: string
  responses:
    UniquePrimitiveArrayResponse:
      description: Response body that is a primitive array with uniqueItems
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UniqueStringArray'
        application/xml:
          schema:
            $ref: '#/components/schemas/UniqueStringArray'
Generation Details

Default generation, without Set to Array type mapping.

Steps to reproduce

Generate typescript-fetch client for the provided example.

Related issues/PRs

N/A

Suggest a fix

I will fix it myself.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions