OpenAPITools / OpenAPITools/openapi-generator
[BUG][cpp-restsdk][csharp-nancfx] Multiple bugs in C# NancyFx and C++ REST SDK
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
I hope it's OK I'm reporting all the issues I've found this way. It is my knowledge that non of them has been previously reported. Tested them all with OpenAPI 2.
Framework: C# NancyFx
Problem: When returning 204 http status code, it explicitly returns an empty Content-Type header instead of not putting one at all, and returns 200 instead.
Severity: The empty Content-Type on 204 causes the c++ restsdk client to throw an exception because of this.
Temporary workaround: find "autogen_path" -iname "*.cs" | xargs -I {} sed -i 's/return new Response { ContentType = ""};/return new Response { ContentType = null, StatusCode = HttpStatusCode.NoContent };/g' {}
Framework: C# NancyFx
Problem: When defining a property as an integer data type limited by specific enums, instead of returning the enum value, it returns it's enum index which is nonsense.
Severity: Can't define enums for integer types.
Temporary workaround: Defining and registering a custom NancyFx JavaScriptPrimitiveConverter which goes around it.
Framework: C# NancyFx
Problem: Returning a binary string ("application/octet-stream") defines an C# Stream as the result, but NancyFx does not know how to handle it and borks with an error.
Severity: Can't return binary data.
Temporary workaround: Defining an custom NancyFx IResponseProcessor for application/octet-stream which streams the returned Stream.
Framework: C# NancyFx
Problem: No automatic way to handle multiple produces.
Severity: Can't use multiple produces.
Temporary workaround: You can override the routing code for a specific endpoint and make it call different functions per provides.
Framework: C++ REST SDK
Problem: When receiving a binary string, HttpContent isn't allocated and the program crashes, also the header file points to the wrong location in the Model directory.
Severity: Can't receive binary strings, also runtime crash.
Temporary workaround:
find "autogen_path/api" -iname "*.h" | xargs -I {} sed -i 's/#include "HttpContent.h"/#include "..\/HttpContent.h"/g' {}
find "autogen_path/api" -iname "*.cpp" | xargs -I {} sed -i 's/std::shared_ptr<HttpContent> localVarResult;/std::shared_ptr<HttpContent> localVarResult(new HttpContent());/g' {}
Framework: C++ REST SDK
Problem: When an property is defined as a double number, and has no decimal dot in the data, the generation ignores the value.
Severity: Can't accept double numbers without dots.
Temporary workaround: Fix bool ModelBase::fromJson( const web::json::value& val, double & outVal ) and bool ModelBase::fromJson( const web::json::value& val, float & outVal )
Framework: C++ REST SDK
Problem: Instead of reusing the base http connection between requests, it creates a new one per function call.
Severity: Performence penalty, each function call sets up a new connection, no http keep-alive.
Temporary workaround: ?
Framework: C++ REST SDK
Problem: Cannot define model names to start with a number (in some others you can, and they are renamed on the fly).
Severity: ?
Temporary workaround: Don't put a number in the start of the model name.
Framework: C++ REST SDK
Problem: The CMake library for the auto generated model / api header files marks them as private and require manual adding them to parent project.
Severity: ?
Temporary workaround: Manually include the required header files.
Framework: C# NancyFx
Problem: Sometimes added ghost "using ;" to Modules files.
Severity: Code does not compile.
Temporary solution: bash find "autogen_path" -iname "*.cs" | xargs -I {} sed -i "s/using ;//g" {}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Split the report into separate issues, then reproduce each case from an OpenAPI 2 input in the generated C# NancyFx and C++ REST SDK outputs. Inspect the generated files under autogen_path and the mentioned ModelBase::fromJson overloads first. Done means each confirmed bug has a focused change and regression coverage for its affected generator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100