Skip to content

Commit

Permalink
chore: bump openapi-generator (#3696)
Browse files Browse the repository at this point in the history
* chore: bump openapi-generator
  • Loading branch information
alnr authored Jan 22, 2024
1 parent fbf39dd commit aa8a364
Show file tree
Hide file tree
Showing 68 changed files with 4,078 additions and 2,815 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ sdk: .bin/swagger .bin/ory node_modules
-g go \
-o "internal/httpclient" \
--git-user-id ory \
--git-repo-id hydra-client-go \
--git-host github.com
(cd internal/httpclient && go mod edit -module github.com/ory/hydra-client-go/v2)
--git-repo-id hydra-client-go/v2 \
--git-host github.com \
--api-name-suffix "Api" \
--global-property apiTests=false

make format

Expand Down
11 changes: 7 additions & 4 deletions cmd/cmd_import_jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ the imported keys will be added to that set. Otherwise, a new set will be create

key = cli.ToSDKFriendlyJSONWebKey(key, "", "")

var buf bytes.Buffer
var jsonWebKey hydra.JsonWebKey
type jwk hydra.JsonWebKey // opt out of OpenAPI-generated UnmarshalJSON
var (
buf bytes.Buffer
jsonWebKey jwk
)
if err := json.NewEncoder(&buf).Encode(key); err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Could not encode key from `%s` to JSON: %s", src, err)
return cmdx.FailSilently(cmd)
}

if err := json.NewDecoder(&buf).Decode(&jsonWebKey); err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Could not decode key from `%s` to JSON: %s", src, err)
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Could not decode key from `%s` from JSON: %s", src, err)
return cmdx.FailSilently(cmd)
}

Expand All @@ -107,7 +110,7 @@ the imported keys will be added to that set. Otherwise, a new set will be create
return cmdx.FailSilently(cmd)
}

keys[src] = append(keys[src], jsonWebKey)
keys[src] = append(keys[src], hydra.JsonWebKey(jsonWebKey))
}

imported := make([]hydra.JsonWebKey, 0, len(keys))
Expand Down
2 changes: 1 addition & 1 deletion internal/httpclient/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.1
7.2.0
44 changes: 21 additions & 23 deletions internal/httpclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ 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
```

Put the package under your project folder and add the following in import:

```golang
import openapi "github.com/ory/hydra-client-go"
```go
import openapi "github.com/ory/hydra-client-go/v2"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
```go
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```

Expand All @@ -38,17 +38,17 @@ Default configuration comes with `Servers` field that contains server objects as

### Select Server Configuration

For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
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)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
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",
})
Expand All @@ -60,9 +60,9 @@ Note, enum values are always validated and all unused variables are silently ign

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps.

```
```go
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
Expand Down Expand Up @@ -179,34 +179,32 @@ Class | Method | HTTP request | Description
## Documentation For Authorization



Authentication schemes defined for the API:
### basic

- **Type**: HTTP basic authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
```go
auth := context.WithValue(context.Background(), openapi.ContextBasicAuth, openapi.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
```


### bearer

- **Type**: HTTP Bearer token authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
```go
auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
```


### oauth2


Expand All @@ -220,20 +218,20 @@ r, err := client.Service.Operation(auth, args)

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
```go
auth := context.WithValue(context.Background(), openapi.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 */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
```

Expand Down
Loading

0 comments on commit aa8a364

Please sign in to comment.