Additional response headers found in schema:

I have no idea how to fix this validation error:
“Additional response headers found in schema:”

Would be grateful for any assistance!

Screenshot of the problem
image

Screenshot of response header after successful request:
image

schema:

     "/api/auth": {
    "post": {
    "description": "Authenticates a user.  On successful authentication, the response returns a Bearer token.",
    "requestBody": {
        "content": {
            "application/json": {
                "schema": {
                    "type": "object",
                    "properties": {
                        "username": {"type":"string", "minLength": 1},
                        "password": {"type":"string", "minLength": 1}
                    },
                    "example": {
                        "username": "testuser1",
                        "password": "password",
                    }
                }
            }
        }
    },
    "responses": {
        "200": {
        "description": "Success",
        "content": {
            "application/json": {
            "schema": {
                "type": "array",
                "properties": {  
                    "token": {"type":"string"}
                }
            }
            }
        }
        },
        "401": {
        "description": "Unauthorized",
        "content": {
            "application/json": {
            "schema": {"$ref": "#/components/schemas/Error"},
            "example": {
                "code": "UnauthorizedError",
                "message": "Provided user admin1 was invalid"
            }
            }
        }
        },
        "default": {
        "description": "Unexpected error",
        "content": {
            "application/json": {
            "schema": {"$ref": "#/components/schemas/Error"}
            }
        }
        }
    } 
    }}

I don’t see a headers object describing the possible headers, including application/json.

Maybe I am wrong, but your schema does not look right.

does this mean that the schema should have a headers object? I am having trouble fixing my schema

Yes. May I suggest you look into the Swagger editor. https://editor.swagger.io/

This can help pinpoint your mistake.

Start from scratch, smart small and look over the OAS specification. Don’t just randomly add properties.

1 Like