OpenAPITools / OpenAPITools/openapi-generator

[REQ] [C++][Pistache] Generation of response message in API handler

Open
#20,144 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

When I'm using pistache C++ server generator (cpp-pistache-server), the API looks pretty clean, except that it doesn't generate the response message for me in the api. It's only defined in the model, but not used in the api.
Instead there is only the ResponseWriter which accepts any string value.

Describe the solution you'd like

I would like if the api would state the response message in the function signature. Either in the return value, or as a passed by reference in the argument of the api method. The response writer is not needed in my use case, just the struct I need to return according to the OpenApiFile.

Describe alternatives you've considered

Now I need to specify (and therefore know) what response it is we should generate and write it myself. If this response changes I'm not at compile time reminded of this contract change.

Additional context

Current interface:

    virtual void drive_motor_do_command(const MotorCommand& MotorCommand,
                                        Pistache::Http::ResponseWriter& response);

Preferred interface:

    virtual ReturnCode drive_motor_do_command(const MotorCommand& MotorCommand);

Or

    virtual void drive_motor_do_command(const MotorCommand& MotorCommand,
                                       ReturnCode& response);

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 by tracing the cpp-pistache-server API handler generation from the OpenAPI file through the generated model and current ResponseWriter-based interface. Compare how response messages are represented in the model with the proposed return-value or reference-based signatures. Done means the generated API exposes the declared response type while preserving the intended response-writing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.