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] Lack of Support for RFC 7807 and application/problem+json Content Type #76

Closed lucasvenez closed 9 months ago

lucasvenez commented 9 months ago

Description

The Python OpenAPI3-parser library currently lacks support for RFC 7807, leading to an issue when handling the application/problem+json content type. According to RFC 7807, this content type is commonly used for representing errors in a machine-readable format, allowing for standardized error responses.

Problem

When attempting to process errors using the application/problem+json content type, the library raises an exception, hindering the smooth integration of error handling in accordance with RFC 7807.

Expected Behavior

The OpenAPI3-parser library should provide support for RFC 7807, allowing users to seamlessly handle error responses in the specified JSON format without encountering exceptions.

Steps to Reproduce

  1. Define an OpenAPI specification that includes error responses conforming to RFC 7807.
  2. Implement a build process using the OpenAPI3-parser library.
  3. Trigger an error response with the application/problem+json content type.

Current Behavior

The library raises an exception when attempting to process the error response with the application/problem+json content type.

Proposed Solution

Implement support for RFC 7807 in the OpenAPI3-parser library, ensuring that the application/problem+json content type is handled without raising exceptions. This enhancement will enable users to seamlessly integrate standardized error handling into their applications.

Updating the enum ContentType in the file openapi_parser/enumeration.py by adding an entry `JSON_PROBLEM = 'application/problem+json' resolves this issues.

Impact

This improvement will benefit users who rely on RFC 7807 for consistent error representations and enhance the overall compatibility of the OpenAPI3-parser library with industry standards.

manchenkoff commented 9 months ago

Hey @lucasvenez, considering the current implementation, your proposal sounds valid to me, I will check your PR asap! Thanks for bringing this up šŸ‘

manchenkoff commented 9 months ago

PR is merged, new version was published - v1.1.15 šŸ”„