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

feat(api): homogenize response schema for errors #562

Merged
merged 2 commits into from
Jun 19, 2023
Merged

Conversation

matthiasschaub
Copy link
Collaborator

@matthiasschaub matthiasschaub commented Apr 28, 2023

Description

Homogenize API response schema for errors.

Default JSON error like ValidationErrors by Pydantic/FastAPI:

{
    "detail": [
        {
            "loc": [
                "path",
                "item_id"
            ],
            "msg": "value is not a valid integer",
            "type": "type_error.integer"
        }
    ]
}

The PR changes the response schema for errors in OQT to:

{
    "apiVersion": __version__,
    "type": "type_error.integer"
    "detail": [
        {
            "loc": [
                "path",
                "item_id"
            ],
            "msg": "value is not a valid integer",
            "type": "type_error.integer"
        }
    ]
}

Whereas ["detail"]["loc"] and ["detail"]["type"] are optional and only in use for Request Validation Errors raised by Pydantic/FastAPI.

Corresponding issue

Closes #

New or changed dependencies

Checklist

  • I have updated my branch to main (e.g. through git rebase main)
  • My code follows the style guide and was checked with pre-commit before committing
  • I have commented my code
  • I have updated the CHANGELOG.md
  • tests

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Co-authored-by: Johannes Visintini <johannes.visintini@heigit.org>
@matthiasschaub matthiasschaub merged commit dc93579 into main Jun 19, 2023
2 checks passed
@matthiasschaub matthiasschaub deleted the api-errors branch June 19, 2023 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants