OpenAPITools / OpenAPITools/openapi-generator
[BUG][cpp-restsdk]How to define API with response type "text/html"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I want to write a API request and generate it in cpp-restsdk.
Content Types are as follows:
Request Content Type: "application/x-www-form-urlencoded"
Response Content Type: "text/html"
openapi-generator version v5.0.1
OpenAPI declaration file content or url
/api/v1/user/login:
post:
tags:
- login/logout
summary: Login as a user.
description: Send login request
operationId: loginUser
requestBody:
description: Send login credentials.
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
username:
type: string
password:
type: string
required:
- username
- password
example:
username: usr
password: '123'
responses:
'200':
content:
text/html:
schema:
type: string
tags:
- name: login/logout
description: 'login, logout operations'
After API Code generation, i noticed code block for text/plain were added instead of text/html.
Currently, i am manually editing the parts that are not generated correctly.
So how to fix this problem.
Generated Code:
localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain");
else if(localVarResponseHttpContentType == utility::conversions::to_string_t(**"text/plain"**))
{
localVarResult = localVarResponse;
}
Generation Details
npx openapi-generator-cli generate -g cpp-restsdk -i test.yaml -o ./cpp
Steps to reproduce
Related issues/PRs
Suggest a fix
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
Start with the supplied OpenAPI declaration and run the shown openapi-generator CLI command for the cpp-restsdk generator. Inspect the generated response-content-type handling, where text/html is emitted as text/plain, and verify that the generated client preserves the declared text/html response type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100