google / google/gnostic

Adding Error message to OpenAPI component schema

Open
#378 4 comments 6 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

Is it possible to add a protobuff message to an OpenAPI schema component output?

I want to have a way to add a reference for an error case like 403.

Example:
```protobuf
service ExampleAPI {
rpc GetCurrentUser(google.protobuf.Empty) returns (UserResponse) {
option (google.api.http) = {
get: "/v1/current-user"
};
option (gnostic.openapi.v3.operation) = {
description: "";
responses: {
response_or_reference: {
name: "403"
value: {
response: {
description: "Forbidden"
content: {
additional_properties: [{
name: "*/*";
value: {
schema: {
reference: { _ref: "#/components/schemas/ErrorResponse"; }
}
}
}
}]
}
}
}
}
}
};
}
}

message UserResponse {
int id = 1;
string name = 2;
}

message ErrorResponse {
string message = 1;
}
```

Is this possible right now, or what would be the way to go for adding Error messages to OpenAPI Spec component?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.