Skip to content

cpp-restsdk incorrectly handles object properties containing dash/minus ("-") character #12289

@kesheshyan

Description

@kesheshyan

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?
    Compilable C++ code
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
OpenAPI declaration file content or url
{
  "openapi": "3.0.0",
  "components": {
    "schemas": {
      "StringMap": {
        "type": "object",
        "properties": {
          "zh-Hans": {
            "type": "string",
            "description": "Text in Chinese (Simplified)."
          },
      }
    }
  }
}
Description

Generator: cpp-restsdk-client
Produces uncompilable code if there is a "-" (or other characters like a space etc.) in a property name of an object.

if(multipart->hasContent(utility::conversions::to_string_t(U("zh-Hant"))))
{
    utility::string_t refVal_zh-Hant;
    ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("zh-Hant"))), refVal_zh-Hant );
    setZhHant(refVal_zh-Hant);
}
Suggest a fix

#12288

Resulting cpp code looks like this:

 if(multipart->hasContent(utility::conversions::to_string_t(U("zh-Hant"))))
{
    utility::string_t refVal_setZhHant;
    ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("zh-Hant"))), refVal_setZhHant );
    setZhHant(refVal_setZhHant);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions