Skip to content

Commit

Permalink
[cpp-restsdk] handle OneOf on property level in fromJson (OpenAPITool…
Browse files Browse the repository at this point in the history
  • Loading branch information
larsme committed Oct 15, 2024
1 parent 1214ad7 commit 1e43a24
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public:
return true;
}

template <std::size_t I = 0>
bool fromJson(const web::json::value& json) {
// try to convert json to each oneOf option until fromJson<option> returns true
if constexpr (I < std::variant_size_v<VariantType>) {
bool parsed = fromJson<std::variant_alternative_t<I, VariantType>>(json);
return parsed ? true : fromJson<I + 1>(json);
}
return false;
}

void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const;

template<typename Target>
Expand Down

0 comments on commit 1e43a24

Please sign in to comment.