Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Type application/json;charset=UTF-8 is not serialized/deserialized as JSON #767

Open
tnaumann-wecg opened this issue Oct 20, 2023 · 0 comments
Labels

Comments

@tnaumann-wecg
Copy link

Jane version(s) affected: 7.5.4

Description
If a JSON content type is including a charset suffix like application/json;charset=UTF-8, it is not serialized or deserialzed (depending on if it is present in request or response body schema) to/from JSON.

How to reproduce

openapi: 3.0.3
info:
  title: content-type-reproducer
  version: v1
servers:
  - url: https://api.example.com
paths:
  /post/data:
    post:
      operationId: operation
      requestBody:
        content:
          application/json;charset=UTF-8:
            schema:
              type: object
              properties:
                prop:
                  type: string
      responses:
        200:
          description: success
          content:
            application/json;charset=UTF-8:
              schema:
                type: object
                properties:
                  prop2:
                    type: string

The generated Endpoint will neither encode the request body to JSON (leading to a Type Error when passing the body data to StreamFactory::createStream) nor decode a JSON response to object.

Possible Solution
It seems like a similar bug was fixed in #115. I managed to hack a workaround by modifying RequestBodyGenerator, to only check the content type string before the ; character against the registered generators.
If this sounds like a legit approach I'd be willing to submit a PR containing this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant