@@ -25,16 +25,19 @@ webrpc-gen -schema=./proto.ridl -target=github.com/webrpc/
[email protected] -ou
2525## Set custom template variables
2626Change any of the following default values by passing ` -option="Value" ` CLI flag to webrpc-gen.
2727
28- | webrpc-gen -option | Default value | Example value |
29- | ----------------------| ----------------------------| ------------------------------------------------------------------------|
30- | ` -title ` | ` {Services[0].Name} API ` | ` "Example API" ` |
31- | ` -apiVersion ` | ` "" ` | ` v22.10.25 ` |
32- | ` -serverUrl ` | ` "" ` | ` https://api.example.com ` |
33- | ` -serverDescription ` | ` "" ` | ` "Staging API" ` |
34- | ` -servers ` | ` "" ` | ` http://localhost:8080;description,http://localhost:8081;description ` |
28+ | webrpc-gen -option | Default value | Example value |
29+ | ------------------------| --------------------------| --------------------------------------------------------------------------------------------------------------------------------------|
30+ | ` -title ` | ` {Services[0].Name} API ` | ` "Example API" ` |
31+ | ` -apiVersion ` | ` "" ` | ` v22.10.25 ` |
32+ | ` -serverUrl ` | ` "" ` | ` https://api.example.com ` |
33+ | ` -serverDescription ` | ` "" ` | ` "Staging API" ` |
34+ | ` -servers ` | ` "" ` | ` http://localhost:8080;description,http://localhost:8081;description ` |
35+ | ` -securityAnnotation ` | ` "" ` | ` @auth ` |
36+ | ` -securitySchemes ` | ` "" ` | ` {"ApiKeyAuth":{"type":"apiKey", "in":"header", "description":"Access key for authenticating requests", "name":"X-Access-Key"}} ` |
37+
3538
3639Example:
37- - server url and server description will become part of the servers format in the end to keeep it backward compatible
40+ - server url and server description will become part of the servers format in the end to keep it backward compatible
3841- means that the result will be ` server="http://localhost:8080;description,http://localhost:8081;description,https://api.example.com;Production" `
3942```
4043webrpc-gen \
@@ -48,6 +51,36 @@ webrpc-gen \
4851 -servers="http://localhost:8080;description,http://localhost:8081;description"
4952```
5053
54+ - ` securityAnnotation ` must match the custom annotation you are using in your project to describe ACL for specific service methods
55+ - ` securitySchemes ` give you possibility to pass an openapi security schemes which are later matched by your custom ` acl annotation ` . In this example it's an ` @auth ` annotation.
56+ Example with security annotation:
57+ ```
58+ // proto.ridl
59+ service ExampleService
60+ @auth:"ApiKeyAuth,ServiceAuth"
61+ - GetUserV2(header: map<string,string>, userID: uint64) => (profilePicture: string)
62+
63+ // Makefile
64+ SECURITY_SCHEMES="{ \
65+ 'ApiKeyAuth': { \
66+ 'type': 'apiKey', \
67+ 'in': 'header', \
68+ 'description': 'Project access key for authenticating requests', \
69+ 'name': 'X-Access-Key' \
70+ }, \
71+ }"; \
72+ webrpc-gen \
73+ -schema=./proto.ridl \
74+ -target=./ \
75+ -out=./openapi.gen.yaml \
76+ -title="Example webrpc API" \
77+ -apiVersion="v22.11.8" \
78+ -serverUrl=https://api.example.com \
79+ -serverDescription="Production" \
80+ -securityAnnotation="@auth" \
81+ -securitySchemes="$$SECURITY_SCHEMES"
82+ ```
83+
5184# Open in Swagger UI
5285
5386Open generated documentation in Swagger editor:
0 commit comments