[BUG] swift5 generator does not support Content-Type with appended charset
Created by: Jonas1893
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? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
If a spec defines a content-type with an appended charset, generated client currently crashes as we are running into the fatalError
because we are testing for equality and not for contains
in Alamofire*/URLSessionImplementations.swift
openapi-generator version
6.2.1 and earlier
OpenAPI declaration file content or url
Consider any request that appends a charset to a content-type, either in the request header or request body like e.g. so:
requestBody:
content:
application/x-www-form-urlencoded; charset=utf-8:
Generation Details
Steps to reproduce
Use petstore-with-deprecated-fields.yaml
and modify requestBody of post '/pet/{petId}'
to use application/x-www-form-urlencoded; charset=utf-8
like described here
Using this API will now lead to a crash
Related issues/PRs
Suggest a fix
For content-type checks (where we fall through to fatalError) we should not check for equality but rather for contains
or hasPrefix
. I'll open a PR for it for easier discussion