OpenAPITools / OpenAPITools/openapi-generator
[BUG][cpp-pistache-server] Generated code for query parameters which refer to a schema in the components section/another file are not fully qualified
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 (example)?
- 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
The status parameter in the following specification is an enum string. It refers to the Status schema in the components section. The generated method for get_sessions is:
virtual void get_sessions(const std::optional<Status> &status, Pistache::Http::ResponseWriter &response) = 0;
While it is expected to be:
virtual void get_sessions(const std::optional<org::openapitools::server::model::Status> &status, Pistache::Http::ResponseWriter &response) = 0;
openapi-generator version
6.4.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Foo
version: '1.0'
paths:
/sessions:
get:
operationId: get_sessions
parameters:
- name: status
in: query
schema:
$ref: '#/components/schemas/Status'
responses:
'200':
description: OK
components:
schemas:
Status:
type: string
enum:
- running
- terminated
Generation Details
openapi-generator generate -g cpp-pistache-server -i foo.yaml
Suggest a fix
I think the following line should be changed to prepend the namespace to the data type:
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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java around line 303, then generate the provided foo.yaml with the cpp-pistache-server generator. Verify that query parameters referencing component schemas use the fully qualified model type, including org::openapitools::server::model::Status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java, openapi
- Domain
- backend-api-design, devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100