mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
[Style][Go] standardize the format of mustache (tiny change) (#17363)
* fix: change indent style to tab in the mustache to generate Go code * docs: standardize the language names for code blocks * docs: change indent style to tab in the code blocks * update: regenerate samples * `./bin/generate-samples.sh ./bin/configs/*.yaml`
This commit is contained in:
parent
10da7a3c5a
commit
004c7e8c8d
@ -21,7 +21,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
{{#hasOAuthMethods}}
|
||||
go get golang.org/x/oauth2
|
||||
@ -31,13 +31,13 @@ go get golang.org/x/net/context
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import {{packageName}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -49,7 +49,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `{{packageName}}.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -57,7 +57,7 @@ ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerInde
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `{{packageName}}.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -71,7 +71,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `{{packageName}}.ContextOperationServerIndices` and `{{packageName}}.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), {{packageName}}.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -112,7 +112,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
{{packageName}}.ContextAPIKeys,
|
||||
@ -130,7 +130,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "BEARER_TOKEN_STRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
@ -141,7 +141,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), {{packageName}}.ContextBasicAuth, {{packageName}}.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
@ -155,7 +155,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
authConfig := {{packageName}}.HttpSignatureAuth{
|
||||
KeyId: "my-key-id",
|
||||
PrivateKeyPath: "rsa.pem",
|
||||
@ -193,14 +193,14 @@ Example
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
|
||||
```golang
|
||||
```go
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
|
@ -13,20 +13,20 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/net/context
|
||||
```
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -38,7 +38,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `openapi.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -46,7 +46,7 @@ ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -60,7 +60,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -126,7 +126,7 @@ Authentication schemes defined for the API:
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), openapi.ContextBasicAuth, openapi.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
@ -140,7 +140,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
@ -13,7 +13,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/oauth2
|
||||
go get golang.org/x/net/context
|
||||
@ -21,13 +21,13 @@ go get golang.org/x/net/context
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import petstore "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `petstore.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -47,7 +47,7 @@ ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `petstore.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -61,7 +61,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `petstore.ContextOperationServerIndices` and `petstore.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -182,14 +182,14 @@ Authentication schemes defined for the API:
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
|
||||
```golang
|
||||
```go
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
@ -209,7 +209,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
petstore.ContextAPIKeys,
|
||||
@ -230,7 +230,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
petstore.ContextAPIKeys,
|
||||
@ -247,7 +247,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextBasicAuth, petstore.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
|
@ -13,20 +13,20 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/net/context
|
||||
```
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import x_auth_id_alias "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -38,7 +38,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `x_auth_id_alias.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), x_auth_id_alias.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -46,7 +46,7 @@ ctx := context.WithValue(context.Background(), x_auth_id_alias.ContextServerInde
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `x_auth_id_alias.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), x_auth_id_alias.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -60,7 +60,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `x_auth_id_alias.ContextOperationServerIndices` and `x_auth_id_alias.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), x_auth_id_alias.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -101,7 +101,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
x_auth_id_alias.ContextAPIKeys,
|
||||
@ -122,7 +122,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
x_auth_id_alias.ContextAPIKeys,
|
||||
|
@ -13,7 +13,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/oauth2
|
||||
go get golang.org/x/net/context
|
||||
@ -21,13 +21,13 @@ go get golang.org/x/net/context
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import petstore "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `petstore.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -47,7 +47,7 @@ ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `petstore.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -61,7 +61,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `petstore.ContextOperationServerIndices` and `petstore.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -104,14 +104,14 @@ Authentication schemes defined for the API:
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
|
||||
```golang
|
||||
```go
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
|
@ -13,7 +13,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/oauth2
|
||||
go get golang.org/x/net/context
|
||||
@ -21,13 +21,13 @@ go get golang.org/x/net/context
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
```go
|
||||
import petstore "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
```go
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Default configuration comes with `Servers` field that contains server objects as
|
||||
|
||||
For using other server than the one defined on index 0 set context value `petstore.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
@ -47,7 +47,7 @@ ctx := context.WithValue(context.Background(), petstore.ContextServerIndex, 1)
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `petstore.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
@ -61,7 +61,7 @@ Each operation can use different server URL defined using `OperationServers` map
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `petstore.ContextOperationServerIndices` and `petstore.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
```go
|
||||
ctx := context.WithValue(context.Background(), petstore.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
@ -205,14 +205,14 @@ Authentication schemes defined for the API:
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
|
||||
```golang
|
||||
```go
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
@ -232,7 +232,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
petstore.ContextAPIKeys,
|
||||
@ -253,7 +253,7 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
petstore.ContextAPIKeys,
|
||||
@ -270,7 +270,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextBasicAuth, petstore.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
@ -284,7 +284,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
auth := context.WithValue(context.Background(), petstore.ContextAccessToken, "BEARER_TOKEN_STRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
@ -295,7 +295,7 @@ r, err := client.Service.Operation(auth, args)
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
```go
|
||||
authConfig := petstore.HttpSignatureAuth{
|
||||
KeyId: "my-key-id",
|
||||
PrivateKeyPath: "rsa.pem",
|
||||
|
@ -68,3 +68,4 @@ func (c *Container) UploadFile(ctx echo.Context) error {
|
||||
Message: "Hello World",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -35,3 +35,4 @@ func (c *Container) PlaceOrder(ctx echo.Context) error {
|
||||
Message: "Hello World",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -67,3 +67,4 @@ func (c *Container) UpdateUser(ctx echo.Context) error {
|
||||
Message: "Hello World",
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user