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

Missing HTTP response codes in OpenAPI schema #763

Closed
ml-evs opened this issue Mar 26, 2021 · 1 comment · Fixed by #846
Closed

Missing HTTP response codes in OpenAPI schema #763

ml-evs opened this issue Mar 26, 2021 · 1 comment · Fixed by #846
Assignees
Labels
enhancement New feature or request OPTIMADE v1.0 A label for tagging issues/PRs that are required for compliance with v1.0 of the OPTIMADE spec schema Concerns the schema models server Issues pertaining to the example server implementation suggestions

Comments

@ml-evs
Copy link
Member

ml-evs commented Mar 26, 2021

While trying out the schemathesis library for fuzzy API testing based on schemas, I discovered that the response codes we provide in the OpenAPI schemas are limited.

I guess we need to somehow we make our exceptions handlers known to FastAPI? It seems like there is something a bit strange with our ErrorResponse being a valid "successful response", presumably because of the way we use our exception handlers. See e.g. for the links endpoint:

          "responses": {
            "200": {
              "description": "Successful Response",
              "content": {
                "application/json": {
                  "schema": {
                    "title": "Response Get Links Links Get",
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/LinksResponse"
                      },
                      {
                        "$ref": "#/components/schemas/ErrorResponse"
                      }
                    ]
                  }
                }
              }
            },
            "422": {
              "description": "Validation Error",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/HTTPValidationError"
                  }
                }
              }
            }
          }
        }
      },

It would be nice to add e.g. 553 VersionNotSupported and other errors that are buried in the spec so that automated tools can use our API more effectively.

@ml-evs ml-evs added enhancement New feature or request schema Concerns the schema models server Issues pertaining to the example server implementation suggestions OPTIMADE v1.0 A label for tagging issues/PRs that are required for compliance with v1.0 of the OPTIMADE spec labels Mar 26, 2021
@CasperWA
Copy link
Member

I think this is due to the response_model value we put for endpoint functions. We'd need to differentiate further in the same decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OPTIMADE v1.0 A label for tagging issues/PRs that are required for compliance with v1.0 of the OPTIMADE spec schema Concerns the schema models server Issues pertaining to the example server implementation suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants