retaildevcrews / helium

A secure Web API reference application using Managed Identity, Key Vault, and Cosmos DB that is designed to be deployed to Azure App Service or AKS.
MIT License
6 stars 7 forks source link

Standardized error 400 messages - API Guidelines #514

Closed dsturgell closed 3 years ago

dsturgell commented 4 years ago

Apply API guidelines as per CPR feedback across all relevant repositories.

Next steps:

Update:

Objectives:

Opportunities:

Suggested JSON format:


{
    "type": "https://github.com/retaildevcrews/helium/blob/main/docs/ParameterValidation.md#movies",
    "title": "Your request parameters did not validate",
    "status": 400,
    "detail": "One or more invalid parameters were specified.",
    "instance": "/api/movies?year=987&pageSize=999999&genre=1",
    "validationErrors": [
        {
            "code": "InvalidValue",
            "target": "Year",
            "message": "The parameter 'Year' should be between 1874 and 2025."
        },
        {
            "code": "InvalidValue",
            "target": "Genre",
            "message": "The parameter 'Genre' should be between 3 and 20 characters."
        },
        {
            "code": "InvalidValue",
            "target": "PageSize",
            "message": "The parameter 'PageSize' should be between 1 and 1000."
        }
    ]
}

References #493

aflinchb commented 4 years ago

Link to our Parameter Validation spec: https://github.com/retaildevcrews/helium/blob/master/docs/ParameterValidation.md