Skip to content

Commit

Permalink
feat: Generate Go client
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Aug 2, 2022
1 parent 114e4ae commit 68670a6
Show file tree
Hide file tree
Showing 41 changed files with 6,941 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ tasks:
- build-image
cmds:
- docker run --rm github.com/numary/{{.COMPONENT}}
generate-client:
- >
docker run --rm
-w /local
-v ${PWD}:/local
openapitools/openapi-generator-cli:latest generate
-i swagger.yaml
-g go
-o ./pkg/client
--git-user-id=numary
--git-repo-id=auth
-p packageVersion=latest
-p isGoSubmodule=true
-p packageName=authclient
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:generate task generate-client
package main

import "github.com/numary/auth/cmd"
Expand Down
24 changes: 24 additions & 0 deletions pkg/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof
23 changes: 23 additions & 0 deletions pkg/client/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
35 changes: 35 additions & 0 deletions pkg/client/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.gitignore
.travis.yml
README.md
api/openapi.yaml
api_default.go
client.go
configuration.go
docs/Client.md
docs/ClientAllOf.md
docs/ClientOptions.md
docs/CreateClientResponse.md
docs/CreateScopeResponse.md
docs/DefaultApi.md
docs/ListClientsResponse.md
docs/ListScopesResponse.md
docs/ReadClientResponse.md
docs/Scope.md
docs/ScopeAllOf.md
docs/ScopeOptions.md
git_push.sh
go.mod
go.sum
model_client.go
model_client_all_of.go
model_client_options.go
model_create_client_response.go
model_create_scope_response.go
model_list_clients_response.go
model_list_scopes_response.go
model_read_client_response.go
model_scope.go
model_scope_all_of.go
model_scope_options.go
response.go
utils.go
1 change: 1 addition & 0 deletions pkg/client/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.1.0-SNAPSHOT
8 changes: 8 additions & 0 deletions pkg/client/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go

install:
- go get -d -v .

script:
- go build -v ./

136 changes: 136 additions & 0 deletions pkg/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Go API client for authclient

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: AUTH_VERSION
- Package version: latest
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation

Install the following dependencies:

```shell
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 authclient "github.com/numary/auth/authclient"
```

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

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

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.

### Select Server Configuration

For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), authclient.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`.

```golang
ctx := context.WithValue(context.Background(), authclient.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```

Note, enum values are always validated and all unused variables are silently ignored.

### URLs Configuration per Operation

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.

```
ctx := context.WithValue(context.Background(), authclient.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), authclient.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```

## Documentation for API Endpoints

All URIs are relative to *https://.o.numary.cloud/auth*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**AddScopeToClient**](docs/DefaultApi.md#addscopetoclient) | **Put** /clients/{clientId}/scopes/{scopeId} | Add scope to client
*DefaultApi* | [**AddTransientScope**](docs/DefaultApi.md#addtransientscope) | **Put** /scopes/{scopeId}/transient/{transientScopeId} | Add a transient scope to a scope
*DefaultApi* | [**CreateClient**](docs/DefaultApi.md#createclient) | **Post** /clients | Create client
*DefaultApi* | [**CreateScope**](docs/DefaultApi.md#createscope) | **Post** /scopes | Create scope
*DefaultApi* | [**DeleteClient**](docs/DefaultApi.md#deleteclient) | **Delete** /clients/{clientId} | Delete client
*DefaultApi* | [**DeleteScope**](docs/DefaultApi.md#deletescope) | **Delete** /scopes/{scopeId} | Delete scope
*DefaultApi* | [**DeleteScopeFromClient**](docs/DefaultApi.md#deletescopefromclient) | **Delete** /clients/{clientId}/scopes/{scopeId} | Delete scope from client
*DefaultApi* | [**DeleteTransientScope**](docs/DefaultApi.md#deletetransientscope) | **Delete** /scopes/{scopeId}/transient/{transientScopeId} | Delete a transient scope from a scope
*DefaultApi* | [**ListClients**](docs/DefaultApi.md#listclients) | **Get** /clients | List clients
*DefaultApi* | [**ListScopes**](docs/DefaultApi.md#listscopes) | **Get** /scopes | List scopes
*DefaultApi* | [**ReadClient**](docs/DefaultApi.md#readclient) | **Get** /clients/{clientId} | Read client
*DefaultApi* | [**ReadScope**](docs/DefaultApi.md#readscope) | **Get** /scopes/{scopeId} | Read scope
*DefaultApi* | [**UpdateClient**](docs/DefaultApi.md#updateclient) | **Put** /clients/{clientId} | Update client
*DefaultApi* | [**UpdateScope**](docs/DefaultApi.md#updatescope) | **Put** /scopes/{scopeId} | Update scope


## Documentation For Models

- [Client](docs/Client.md)
- [ClientAllOf](docs/ClientAllOf.md)
- [ClientOptions](docs/ClientOptions.md)
- [CreateClientResponse](docs/CreateClientResponse.md)
- [CreateScopeResponse](docs/CreateScopeResponse.md)
- [ListClientsResponse](docs/ListClientsResponse.md)
- [ListScopesResponse](docs/ListScopesResponse.md)
- [ReadClientResponse](docs/ReadClientResponse.md)
- [Scope](docs/Scope.md)
- [ScopeAllOf](docs/ScopeAllOf.md)
- [ScopeOptions](docs/ScopeOptions.md)


## Documentation For Authorization

Endpoints do not require authorization.


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:

* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`

## Author



Loading

0 comments on commit 68670a6

Please sign in to comment.