swagger-api / swagger-api/swagger-codegen

typescript openapi 3 boolean response result as string

Open
#10,026 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

API return boolean result as a string in the generated code. in the generated code in runtime.ts there is no implementation of ApiResponse for boolean.
so the generated code for the API looks like that:

export class fooApi extends runtime.BaseAPI {

    async fooRaw(requestParameters: fooRequest): Promise<runtime.ApiResponse<boolean>> {
        const queryParameters: runtime.HTTPQuery = {};
        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/foo`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        });

		// this is the problem
        return new runtime.TextApiResponse(response) as any;
    }

    /**
     */
    async foo(): Promise<boolean> {
        const response = await this.fooRaw();
        return await response.value();
    }
}
Swagger-codegen version

openapi-generator-cli-4.2.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated TypeScript runtime.ts and the fooApi response path shown in the issue, then inspect how boolean ApiResponse values are handled. Reproduce the OpenAPI 3 boolean response and verify that the generated foo() method returns a boolean rather than a string; the payload names no test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.