swagger-api / swagger-api/swagger-codegen

[C++][pistache] wrong code generated with the current pistache version due a namespace mismatch

Open
#8,638 1 comment 1 reaction 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

When I try to compile the generated code it give me the following error:

swagger-codegen/samples/server/petstore/pistache-server/api/PetApi.h:82:57: error: ‘Optional’ does not name a type
     virtual void delete_pet(const int64_t &petId, const Optional<Net::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) = 0;
Swagger-codegen version

2.4

Swagger declaration file content or url
Command line used for generation
./bin/pistache-server-petstore.sh
Steps to reproduce
  1. Install pistache (https://github.com/oktal/pistache)
  2. copy json.hpp (from https://github.com/nlohmann/json) to model directory (samples/server/petstore/pistache-server/model)
  3. mkdir build && cd build
  4. cmake ..
  5. make
Related issues/PRs
Suggest a fix/enhancement

Optional namespace has changed. Now it is Pistache::Optional.
Also Http::Header::Raw has change from Net::Http::Header::Raw to Pistache::Http::Header::Raw

With this patch the code generated compiles.
https://github.com/migarma/swagger-codegen/commit/1bb0f0d2f150b012ae249b5d5378034425b061d9#diff-2c140be9bcc3e3a733ac044a8a10992b

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 samples/server/petstore/pistache-server/api/PetApi.h and run ./bin/pistache-server-petstore.sh, then follow the cmake and make reproduction steps. Compare the generated Pistache namespace references with the current Pistache version and the linked patch. Done means the generated petstore server compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.