Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 31 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,67 +1,82 @@
VERSION=v5.2.0
VERSION=v5.4.0
DOCKER_IMAGE="openapitools/openapi-generator-cli:$(VERSION)"
THIS_OS := $(shell go env GOOS)

CGO_ENABLED = 1
CGO_CFLAGS ?=
SDKROOT ?=

CLIENTS = $(shell find clients -type f -name 'config.yaml' -exec dirname "{}" \; | sed 's_/v1__g' | sed 's_clients/__g')

.PHONY: v1 client/go client/java client/javascript/ client/python client/rust/reqwest client/rust/hyper client/ruby client/typescript

ifeq (darwin,$(THIS_OS))
spec: CGO_ENABLED = 0
CGO_CFLAGS=-Wno-undef-prefix
endif

.PHONY: spec
spec: CC ?= $(shell go env CC)
spec: GOOS=$(shell go env GOOS)
spec:
(cd generator && CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) CC=$(CC) CGO_CFLAGS=$(CGO_CFLAGS) go build -o bin/generator && ./bin/generator ../v1/openapi.yaml)

.PHONY: test
test:
(cd ./v1 && go test ./... -v -count=1)

.PHONY: openapi
v1: spec
@echo "==> Building v1 OpenAPI Specification and clients..."
v1: test spec client/go client/java client/javascript/ client/python client/rust/reqwest client/rust/hyper client/ruby client/typescript

client/go:
@echo "==> Building nomad-openapi client for go..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/go/v1/config.yaml

client/java:
@echo "==> Building nomad-openapi client for java..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/java/v1/config.yaml

client/javascript:
@echo "==> Building nomad-openapi client for javascript..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/javascript/v1/config.yaml

client/python/:
@echo "==> Building nomad-openapi client for python using the stable generator..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/python/v1/config.yaml

client/rust/reqwest:
@echo "==> Building nomad-openapi client for rust using the reqwest generator..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/rust/reqwest/v1/config.yaml

client/rust/hyper:
@echo "==> Building nomad-openapi client for rust using the hyper generator..."
@docker run \
--rm \
--volume "$(PWD):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/rust/hyper/v1/config.yaml

client/ruby:
@echo "==> Building nomad-openapi client for ruby..."
@docker run \
--rm \
--volume "$(shell pwd):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/ruby/v1/config.yaml

client/typescript:
@echo "==> Building nomad-openapi client for typescript..."
@docker run \
--rm \
--volume "$(shell pwd):/local" \
$(DOCKER_IMAGE) batch --clean /local/clients/typescript/v1/config.yaml


.PHONY: update-nomad
update-nomad:
(cd generator && go get github.com/hashicorp/nomad)
(cd generator && go get github.com/hashicorp/nomad/api)
(cd generator && go mod tidy)
@go get github.com/hashicorp/nomad
@go mod tidy
$(DOCKER_IMAGE) batch --clean /local/clients/typescript/v1/config.yaml
2 changes: 1 addition & 1 deletion clients/go/v1/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.0
5.4.0
12 changes: 6 additions & 6 deletions clients/go/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ go get golang.org/x/net/context
Put the package under your project folder and add the following in import:

```golang
import sw "./client"
import client "github.com/hashicorp/nomad-openapi/clients/go/v1"
```

To use a proxy, set the environment variable `HTTP_PROXY`:
Expand All @@ -40,15 +40,15 @@ 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 `sw.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), sw.ContextServerIndex, 1)
ctx := context.WithValue(context.Background(), client.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(), sw.ContextServerVariables, map[string]string{
ctx := context.WithValue(context.Background(), client.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```
Expand All @@ -58,14 +58,14 @@ Note, enum values are always validated and all unused variables are silently ign
### URLs Configuration per Operation

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identifield by `"{classname}Service.{nickname}"` string.
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(), sw.ContextOperationServerIndices, map[string]int{
ctx := context.WithValue(context.Background(), client.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), sw.ContextOperationServerVariables, map[string]map[string]string{
ctx = context.WithValue(context.Background(), client.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
Expand Down
Loading