manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
61 stars 33 forks source link

[BUG] Parser doesnt support Text/Json nor application/*+json as valid types for content within request body #67

Closed JohanpG closed 12 months ago

JohanpG commented 12 months ago

Describe the bug When the Open API specification contains context with text/json or application/*+json these are not recognized as valid types.

To Reproduce Steps to reproduce the behavior:

  1. Load a api specification containing any of these types in the request body content:
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/..."
                            }
                        },
                        "text/json": {
                            "schema": {
                                "$ref": "#/components/schemas/..."
                            }
                        },
                        "application/*+json": {
                            "schema": {
                                "$ref": "#/components/schemas/..."
                            }
                        }
                    }
                }
  2. Pass this file to the openapi parser
  3. See error

Expected behavior These types should be valid tpes and the specification file should be validated.

System details (please complete the following information):

Additional context Removing these entries from the file allowed the validaation and loading of the ile into python.

manchenkoff commented 12 months ago

Hey @JohanpG, thanks for opening this issue! I defined only the most popular types in an enumeration, but according to RFC6838 it looks like you can use almost everything there 😄 I probably will reconsider this approach in the next major versions. For now, as a temporary solution, I extended the enumeration with problematic values in #68

manchenkoff commented 12 months ago

Published as v1.1.13

JohanpG commented 12 months ago

Thanks! Yeah I noticed the most common ones were covered, so as a work around I had to manually change the file to remove those types from it, but now i dont need to do that 👍