Bug Report Checklist
Description
When generating a server stub, cpp-restbed-server in my case, all functions reading the values through the keys of a JSON request will automatically stripe certain special characters from the keys set the first letter to uppercase and add an underscore to certain keywords (e.g. operator). This causes the pt.put(), pt.get() etc, which apparently are case sensitive to fail aquiring and passing data to and from a JSON file/array.
The OAS also states that keys are case sensitive
All field names in the specification are case sensitive. This includes all fields that are used as keys in a map, except where explicitly noted that keys are case insensitive.
I haven't confirmed if any other languages/generators are affected by this problem, but it might be possible!
openapi-generator version
OpenAPI declaration file content or url
caseSensitive.yaml
openapi: 3.0.1
info:
title: Case Sensitivity Demo
contact:
email: [email protected]
version: 1.0.0
paths:
/demo:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/demoSchema'
required: true
responses:
'405':
description: 'Validation error'
content: {}
components:
schemas:
demoSchema:
type: object
properties:
$dollarsign:
type: string
§paragraph:
type: string
operator:
type: string
Firstupper:
type: string
noupper:
type: string
midUpper:
type: string
ALLUPPER:
type: string
Generates the following function toJsonString():
std::string DemoSchema::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("dollarsign", m_dollarsign); // should be "$dollarsign"
pt.put("paragraph", m_paragraph); // should be "§paragraph"
pt.put("_operator", m__operator); // should be "operator"
pt.put("Firstupper", m_Firstupper); // alright
pt.put("Noupper", m_Noupper); // should be "noupper"
pt.put("MidUpper", m_MidUpper); // should be "midUpper"
pt.put("ALLUPPER", m_ALLUPPER); // alright
write_json(ss, pt, false);
return ss.str();
}
comments indicate the expected output
Command line used for generation
java -jar openapi-generator-cli.jar generate -i .\caseSensitive.yaml -g cpp-restbed-server -o .\openapi-server\
Steps to reproduce
Simply don't use an uppercase letter as first character for a property key.
Related issues/PRs
Suggest a fix
Bug Report Checklist
Description
When generating a server stub, cpp-restbed-server in my case, all functions reading the values through the keys of a JSON request will automatically stripe certain special characters from the keys set the first letter to uppercase and add an underscore to certain keywords (e.g.
operator). This causes thept.put(),pt.get()etc, which apparently are case sensitive to fail aquiring and passing data to and from a JSON file/array.The OAS also states that keys are case sensitive
I haven't confirmed if any other languages/generators are affected by this problem, but it might be possible!
openapi-generator version
OpenAPI declaration file content or url
caseSensitive.yaml
Generates the following function
toJsonString():comments indicate the expected output
Command line used for generation
java -jar openapi-generator-cli.jar generate -i .\caseSensitive.yaml -g cpp-restbed-server -o .\openapi-server\
Steps to reproduce
Simply don't use an uppercase letter as first character for a property key.
Related issues/PRs
Suggest a fix