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
  • Merge requests
  • !1987

[C++][Client][C++ Rest SDK] Fix path parameters with format

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/zooxco/daniel/fix_format_uuid_url_parameters_upstream into master Jan 25, 2019
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: Peaches491

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Fixes #561 (closed)

Before this change, the following OpenAPI path would cause a compilation failure in the generated C++ code. Specifically, the format: "uuid" was problematic, as it cause the underlying implementation to wrap the string in a std::shared_ptr<>.

paths:
  "/foo/{id}":
    get:
      summary: "Get a specific Fooby ID"
      operationId: "getFoo"
      parameters:
        - name: "id"
          in: "path"
          description: "The UUID of the referenced object"
          required: true
          type: "string"
          format: "uuid"

Yields:

FooApi.cpp: In member function 'virtual pplx::task<std::shared_ptr<Foo> > FooApi::getFoo(std::shared_ptr<std::basic_string<char> >)':
FooApi.cpp:330:184: error: no matching function for call to 'ApiClient::parameterToString(std::shared_ptr<std::basic_string<char> >&)'
     boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(id));
                                                                                                                                                                                        ^
In file included from FooApi.h:23:0,
                 from FooApi.cpp:14:
ApiClient.h:48:30: note: candidate: static utility::string_t ApiClient::parameterToString(utility::string_t)
     static utility::string_t parameterToString(utility::string_t value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:48:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'utility::string_t {aka std::basic_string<char>}'
ApiClient.h:49:30: note: candidate: static utility::string_t ApiClient::parameterToString(int32_t)
     static utility::string_t parameterToString(int32_t value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:49:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'int32_t {aka int}'
ApiClient.h:50:30: note: candidate: static utility::string_t ApiClient::parameterToString(int64_t)
     static utility::string_t parameterToString(int64_t value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:50:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'int64_t {aka long int}'
ApiClient.h:51:30: note: candidate: static utility::string_t ApiClient::parameterToString(float)
     static utility::string_t parameterToString(float value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:51:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'float'
ApiClient.h:52:30: note: candidate: static utility::string_t ApiClient::parameterToString(double)
     static utility::string_t parameterToString(double value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:52:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'double'
ApiClient.h:53:30: note: candidate: static utility::string_t ApiClient::parameterToString(const utility::datetime&)
     static utility::string_t parameterToString(const utility::datetime &value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:53:30: note:   no known conversion for argument 1 from 'std::shared_ptr<std::basic_string<char> >' to 'const utility::datetime&'
ApiClient.h:55:30: note: candidate: template<class T> static utility::string_t ApiClient::parameterToString(const std::vector<_Type>&)
     static utility::string_t parameterToString(const std::vector<T>& value);
                              ^~~~~~~~~~~~~~~~~
ApiClient.h:55:30: note:   template argument deduction/substitution failed:
Api.cpp:330:184: note:   'std::shared_ptr<std::basic_string<char> >' is not derived from 'const std::vector<_Type>'
     boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(id));

This PR adds a templated parameterToString(std::shared_ptr<T>) function, which simply dereferences the shared pointer, and calls the appropriate parameterToString for the templated type T.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/zooxco/daniel/fix_format_uuid_url_parameters_upstream