OpenAPITools / OpenAPITools/openapi-generator
[BUG] typescript-fetch unique item array with primitives in response body is not wrapped into Set
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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)
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reproduction uses the typescript-fetch generator and test-set-response.ts in the set-type-mappings sample. Start by generating the client from the supplied OpenAPI spec and tracing the response conversion; done means the primitive unique-items response is a Set and result.has(...) works without changing the Set-to-Array mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100