Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3462
Closed
Open
Issue created Jul 25, 2019 by Administrator@rootContributor

[REQ] [cpprestsdk] ApiException is not used in the way it is generated

Created by: CyrilleBenard

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

The generator produces code that uses ApiException not in the way it has been intended. Ok, this is not exactly true but let me show what I mean thanks to the PetApi example :

In the file PetApi.cpp line 136 we can see one error treatment throwing an ApiException

if (localVarResponse.status_code() >= 400)
        {
            throw ApiException(localVarResponse.status_code()
                , utility::conversions::to_string_t("error calling addPet: ") + localVarResponse.reason_phrase()
                , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
        }

The 3rd parameter of the ApiException is set with a std::make_shared<std::stringstream> whereas the ApiException shows the corresponding API with a std::shared_ptr<std::istream>

class  ApiException
    : public web::http::http_exception
{
public:
    ApiException( int errorCode
        , const utility::string_t& message
        , std::shared_ptr<std::istream> content = nullptr );
../..
}

Of course this is allowed because a std::stringstream IS A std::istream but when I (the developer) want to handle an ApiException in my application, I retrieve "'only" an std::istream that is not really convenient to use whereas at the origin, the ApiException has been raised with a std::stringstream.

Describe the solution you'd like

What about modifying the ApiException and replace the use of std::istream with std::stringstream ?

Describe alternatives you've considered

N/A

Additional context

N/A

Assignee
Assign to
Time tracking