Open
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
Description
The generator produces the code with the expected http content type but the corresponding code has not been generated, so that an exception is raised.
Generated code looks like :
pplx::task<utility::string_t> SMContextsCollectionApi::postSmContexts(std::shared_ptr<Inline_object> inlineObject)
{
../..
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/related") );
std::shared_ptr<IHttpBody> localVarHttpBody;
utility::string_t localVarRequestHttpContentType;
// use JSON if possible
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
{
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
web::json::value localVarJson;
localVarJson = ModelBase::toJson(inlineObject);
localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
}
// multipart formdata
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
{
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
if(inlineObject.get())
{
inlineObject->toMultipart(localVarMultipart, utility::conversions::to_string_t("inlineObject"));
}
localVarHttpBody = localVarMultipart;
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
}
else
{
throw ApiException(415, utility::conversions::to_string_t("SMContextsCollectionApi->postSmContexts does not consume any supported media type"));
}
../..
}
"multipart/related" is set correctly but just behind its set, there is no corresponding code so that the ApiException (415) is raised
openapi-generator version
4.0.0-SNAPSHOT - hash 4b414d8
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 1.0.0
title: Check generation of cpprest
description: Internal ref filename is check_multipart-related.yaml
servers:
- url: http://localhost:8080
paths:
/sm-contexts:
post:
summary: Create SM Context
tags:
- SM contexts collection
operationId: PostSmContexts
requestBody:
description: representation of the SM context to be created in the SMF
required: true
content:
multipart/related:
schema:
type: object
properties: # Request parts
dataMessage:
type: string
responses:
'200':
description: Everythings gonna be alright
content:
application/json:
schema:
$ref: "#/components/schemas/Content"
default:
description: unexpected error
components:
schemas:
Content:
type: string
Command line used for generation
openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-restsdk -o gen-cpp
Steps to reproduce
Just generate
Related issues/PRs
N/A
Suggest a fix
Generate the corresponding code (>_<) 😂