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

[Feature] Support for a range of response status codes #153

Closed
peombwa opened this issue Dec 9, 2021 · 3 comments · Fixed by #215
Closed

[Feature] Support for a range of response status codes #153

peombwa opened this issue Dec 9, 2021 · 3 comments · Fixed by #215
Assignees
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days type:feature
Milestone

Comments

@peombwa
Copy link
Contributor

peombwa commented Dec 9, 2021

Consider adding support for a range of response status codes as described in OAS 3:

Any HTTP status code can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. A Reference Object can link to a response that is defined in the OpenAPI Object's components/responses section. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character X. For example, 2XX represents all response codes between [200-299]. Only the following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.

e.g., 2XX.

This should ideally be an opt-in feature that should be set via OpenApiConvertSettings.

@irvinesunday irvinesunday self-assigned this Jan 25, 2022
@irvinesunday irvinesunday added this to the 1.1 milestone Jan 25, 2022
@darrelmiller
Copy link
Member

Response should look something like below. Error payload should be the same as it currently is.

openapi: 3.0.1
info:
  title: Wildcard status codes
  version: 1.0.0
paths:
  /:
    get:
      responses:
        2XX:
          description: success
          content:
            application/json:
              schema: 
                type: object
        4XX:
          description: error
          content:
            application/json:
              schema: 
                $ref: "#/components/schemas/error"
        5XX:
          description: error
          content:
            application/json:
              schema: 
                $ref: "#/components/schemas/error"

components:
  schemas:
    error: {}
            

@darrelmiller darrelmiller added the priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days label Mar 1, 2022
@irvinesunday
Copy link
Contributor

@peombwa I believe this issue was fixed with this PR: #167

@peombwa
Copy link
Contributor Author

peombwa commented Apr 26, 2022

@irvinesunday, this issue relates to success (2xx) status code ranges. We've had challenges with certain APIs returning success status codes that are not defined in the OpenAPI files. e.g., microsoftgraph/msgraph-sdk-powershell#907 (comment).

The fix that was made in adds the ability to define error responses on error codes instead of default by baywet · Pull Request #167 · microsoft/OpenAPI.NET.OData (github.com) was for error responses and not success responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days type:feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants