hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client

Home Page:https://heyapi.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Empty JSON request body spec is created as an "unknown" type

brimstony opened this issue Β· comments

Description

See the OpenAPI spec below.

The "body" of the resulting type generated is unknown:
export type MergeDatasubjectUsingPostData = {
/**
* Request body should be empty json.
/
body?: unknown;
path: {
/
*
* The Guid of the merge request
*/
mergeRequestId: string;
};
};

Which leads to the following error in this service:


public static mergeDatasubjectUsingPost(options: Options<MergeDatasubjectUsingPostData>) {
        return (options?.client ?? client).post<MergeDatasubjectUsingPostResponse, MergeDatasubjectUsingPostError>({
            ...options,
            url: '/api/consentmanager/v1/datasubjects/merge/{mergeRequestId}'
        });
    }
Argument of type '{ url: string; query?: Record<string, unknown>; headers?: Record<string, unknown> | HeadersInit; method?: "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"; ... 18 more ...; body?: unknown; }' is not assignable to parameter of type 'RequestOptionsBase'.
  Types of property 'body' are incompatible.
    Type 'unknown' is not assignable to type 'Record<string, unknown> | BodyInit | Record<string, unknown>[]'.ts(2345)

Changing the type from "unknown" to "any" resolves this error

OpenAPI specification (optional)

Full spec located here: https://developer.onetrust.com/onetrust/openapi/62210322bd9404003e1a870c

    "/api/consentmanager/v1/datasubjects/merge/{mergeRequestId}": {
        "post": {
            "description": "Use this API to merge duplicate data subjects in order to consolidate existing Purpose statuses captured across the different identifiers into a single data subject profile.\n\n\u003E πŸ—’ Things to Know\n\u003E \n\u003E - The [Create Scheduled Export](https://developer.onetrust.com/onetrust/reference/schedulemergerequestusingpost) API can be used to create scheduled exports of duplicate data subjects.\n\u003E - The [Generate Export of Duplicate Data Subjects](https://developer.onetrust.com/onetrust/reference/exportduplicatedatasubject) API can be used to generate exports that identify duplicate data subjects.\n\n\u003E πŸ‘ \n\u003E \n\u003E For more information, see [Merging Data Subjects](https://my.onetrust.com/s/article/UUID-87184a50-16e5-185a-36c2-2ca0b2e18372).",
            "operationId": "mergeDatasubjectUsingPOST",
            "parameters": [
                {
                    "description": "The Guid of the merge request",
                    "in": "path",
                    "name": "mergeRequestId",
                    "required": true,
                    "schema": {
                        "type": "string"
                    }
                }
            ],
            "requestBody": {
                "content": {
                    "application/json": {
                        "schema": {
                            "properties": {},
                            "type": "object"
                        }
                    }
                },
                "description": "Request body should be empty json.",
                "x-examples": {
                    "application/json": {}
                }
            },

....
}

Configuration

No response

System information (optional)

"@hey-api/client-fetch": "^0.1.3"
"@hey-api/openapi-ts": "0.46.3",
also tried:
"@hey-api/openapi-ts": "0.46.2",

commented

Thank you for reporting @brimstony

commented

@brimstony could you create a reproducible example on StackBlitz please?