forked from pathwar/pathwar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add swagger annotation (pathwar#56)
feat: add swagger annotation
- Loading branch information
Showing
5 changed files
with
292 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,95 @@ package pathwar.server; | |
import "google/api/annotations.proto"; | ||
import "entity/entity.proto"; | ||
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; | ||
import "protoc-gen-swagger/options/annotations.proto"; | ||
//import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "pathwar.pw/server"; | ||
option (gogoproto.sizer_all) = true; | ||
option (gogoproto.marshaler_all) = true; | ||
option (gogoproto.unmarshaler_all) = true; | ||
|
||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { | ||
host: "api.pathwar.net"; | ||
base_path: "/"; | ||
info: { | ||
title: "Pathwar API"; | ||
version: "1.0", | ||
contact: { | ||
name: "Pathwar Team"; | ||
url: "https://github.com/pathwar/pathwar"; | ||
email: "[email protected]"; | ||
}; | ||
license: { | ||
name: "Apache-2.0"; | ||
url: "https://github.com/pathwar/pathwar/blob/master/LICENSE"; | ||
}; | ||
}; | ||
external_docs: { | ||
url: "https://github.com/pathwar/pathwar"; | ||
description: "More about Pathwar"; | ||
}; | ||
//schemes: HTTP; | ||
schemes: HTTPS; | ||
schemes: WSS; | ||
consumes: "application/json"; | ||
produces: "application/json"; | ||
|
||
security_definitions: { | ||
security: { | ||
key: "BasicAuth"; | ||
value: { | ||
type: TYPE_BASIC; | ||
}; | ||
}; | ||
security: { | ||
key: "ApiKeyAuth"; | ||
value: { | ||
type: TYPE_API_KEY; | ||
in: IN_HEADER; | ||
name: "X-API-Key"; | ||
}; | ||
}; | ||
}; | ||
security: { | ||
security_requirement: { | ||
key: "BasicAuth"; | ||
value: {}; | ||
}; | ||
security_requirement: { | ||
key: "ApiKeyAuth"; | ||
value: {}; | ||
}; | ||
}; | ||
responses: { | ||
key: "403"; | ||
value: { | ||
description: "Returned when the user does not have permission to access the resource."; | ||
}; | ||
}; | ||
responses: { | ||
key: "404"; | ||
value: { | ||
description: "Returned when the resource does not exist."; | ||
schema: { | ||
json_schema: { | ||
type: STRING; | ||
}; | ||
}; | ||
}; | ||
}; | ||
responses: { | ||
key: "418"; | ||
value: { | ||
description: "I'm a teapot."; | ||
schema: { | ||
json_schema: { | ||
ref: ".grpc.gateway.examples.examplepb.NumericEnum"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
service Server { | ||
|
||
|
@@ -74,13 +156,20 @@ service Server { | |
}; | ||
} | ||
|
||
message Void {} | ||
// Void is an empty message | ||
message Void { | ||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = { | ||
example: { value: '{}' }; | ||
}; | ||
} | ||
|
||
// AuthenticateInput contains everything (credentials) to authenticate a user and create a new session. | ||
message AuthenticateInput { | ||
string username = 1; | ||
string password = 2; | ||
} | ||
|
||
// AuthenticateOutput contains a session token (JWT). | ||
message AuthenticateOutput { | ||
string token = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.