Skip to content

Commit

Permalink
repackaging to openapiclient and improving readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ESteanes committed Jul 5, 2024
1 parent e9654e5 commit b928a66
Show file tree
Hide file tree
Showing 205 changed files with 1,436 additions and 1,154 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ endpoitns to drive the UI
`curl https://raw.githubusercontent.com/up-banking/api/master/v1/openapi.json`
3. Generate the REST client code
```
openapi-generator generate \
-i openapi.json \
-g go \
-o ./openapi
--git-user-id esteanes \
--git-repo-id expense-manager
cd ./datafetcher
openapi-generator-cli generate -i openapi.json -g go -o ./openapiclient --additional-properties packageName=openapiclient --git-user-id esteanes --git-repo-id expense-manager
```
4. Format code
`gofmt -s -w .`
5 changes: 5 additions & 0 deletions expense-manager/datafetcher/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenAPI Generator Ignore

go.mod
go.sum
LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Go API client for openapi
# Go API client for openapiclient

The Up API gives you programmatic access to your balances and
transaction data. You can request past transactions or set up
Expand Down Expand Up @@ -27,7 +27,7 @@ go get golang.org/x/net/context
Put the package under your project folder and add the following in import:

```go
import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"
import openapiclient "github.com/esteanes/expense-manager"
```

To use a proxy, set the environment variable `HTTP_PROXY`:
Expand All @@ -42,18 +42,18 @@ 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 `openapi.ContextServerIndex` of type `int`.
For using other server than the one defined on index 0 set context value `openapiclient.ContextServerIndex` of type `int`.

```go
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
ctx := context.WithValue(context.Background(), openapiclient.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`.
Templated server URL is formatted using default variables from configuration or from context value `openapiclient.ContextServerVariables` of type `map[string]string`.

```go
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
ctx := context.WithValue(context.Background(), openapiclient.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```
Expand All @@ -64,13 +64,13 @@ 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 `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps.
Similar rules for overriding default operation server index and variables applies by using `openapiclient.ContextOperationServerIndices` and `openapiclient.ContextOperationServerVariables` context maps.

```go
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
ctx := context.WithValue(context.Background(), openapiclient.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
ctx = context.WithValue(context.Background(), openapiclient.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
Expand Down Expand Up @@ -202,7 +202,7 @@ Authentication schemes defined for the API:
Example

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2010,33 +2010,34 @@ components:
links:
self: self
attributes:
amount: ""
isCategorizable: true
description: description
message: message
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
holdInfo:
amount: ""
foreignAmount:
valueInBaseUnits: 0
currencyCode: currencyCode
value: value
createdAt: 2000-01-23T04:56:07.000+00:00
amount: ""
rawText: rawText
isCategorizable: true
settledAt: 2000-01-23T04:56:07.000+00:00
description: description
message: message
cardPurchasedMethod: ""
roundUp:
amount: ""
boostPortion:
valueInBaseUnits: 6
currencyCode: currencyCode
value: value
status: ""
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
links:
self: self
id: id
Expand Down Expand Up @@ -2103,33 +2104,34 @@ components:
links:
self: self
attributes:
amount: ""
isCategorizable: true
description: description
message: message
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
holdInfo:
amount: ""
foreignAmount:
valueInBaseUnits: 0
currencyCode: currencyCode
value: value
createdAt: 2000-01-23T04:56:07.000+00:00
amount: ""
rawText: rawText
isCategorizable: true
settledAt: 2000-01-23T04:56:07.000+00:00
description: description
message: message
cardPurchasedMethod: ""
roundUp:
amount: ""
boostPortion:
valueInBaseUnits: 6
currencyCode: currencyCode
value: value
status: ""
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
links:
self: self
id: id
Expand Down Expand Up @@ -2169,33 +2171,34 @@ components:
links:
self: self
attributes:
amount: ""
isCategorizable: true
description: description
message: message
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
holdInfo:
amount: ""
foreignAmount:
valueInBaseUnits: 0
currencyCode: currencyCode
value: value
createdAt: 2000-01-23T04:56:07.000+00:00
amount: ""
rawText: rawText
isCategorizable: true
settledAt: 2000-01-23T04:56:07.000+00:00
description: description
message: message
cardPurchasedMethod: ""
roundUp:
amount: ""
boostPortion:
valueInBaseUnits: 6
currencyCode: currencyCode
value: value
status: ""
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
links:
self: self
id: id
Expand Down Expand Up @@ -2853,33 +2856,34 @@ components:
nullable: true
TransactionResource_attributes:
example:
amount: ""
isCategorizable: true
description: description
message: message
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
holdInfo:
amount: ""
foreignAmount:
valueInBaseUnits: 0
currencyCode: currencyCode
value: value
createdAt: 2000-01-23T04:56:07.000+00:00
amount: ""
rawText: rawText
isCategorizable: true
settledAt: 2000-01-23T04:56:07.000+00:00
description: description
message: message
cardPurchasedMethod: ""
roundUp:
amount: ""
boostPortion:
valueInBaseUnits: 6
currencyCode: currencyCode
value: value
status: ""
cashback:
amount: ""
description: description
foreignAmount:
valueInBaseUnits: 1
currencyCode: currencyCode
value: value
properties:
status:
allOf:
Expand Down Expand Up @@ -2926,6 +2930,10 @@ components:
`HELD` at.
foreignAmount:
$ref: '#/components/schemas/TransactionResource_attributes_foreignAmount'
cardPurchasedMethod:
description: A field which describes whether or not the transaction was
purchased using the Up Plastic Card.
nullable: true
settledAt:
description: |
The date-time at which this transaction settled. This field will be
Expand Down
Loading

0 comments on commit b928a66

Please sign in to comment.