Forum Discussion
3 Replies
- prpuritanNew ContributorI'm using this to generate the go code for an API spec - the expected
output includes a go.mod file in the output directory.
Cheers,
Paul
PAUL ROSHAM // Systems Engineer | Pure Storage, Inc.
*Level 18, 567 Collins Street Melbourne, VIC 3000, Australia*
+61 411 198 989 <+61-411-198989> | prosham@purestorage.com- prpuritanNew Contributor
hi - not sure if you saw the attachment. I put the petstore API spec into petstore.json and used the following text in a Makefile. This depends on having Docker desktop (and Xcode on my MacBook) installed.
----------Makefile--------------
#
#
GOMOD_GENERATOR = swaggerapi/swagger-codegen-cli generate -l go
SPEC_GENERATOR = swaggerapi/swagger-codegen-cli generate -l openapi --additional-properties=outputFile
all: petstorepetstore: petstore/go.mod petstore.json
petstore.json:
@curl https://petstore.swagger.io/v2/swagger.json > petstore.json# Use a containerized Go Makefile and Dockerfile
# docker run --rm -v "$(PWD)/$(@D)":/usr/local/go/src/client golang:1.16 go build client%/go.mod: %.json
docker run --rm -v "$(PWD):/src" -w /src $(GOMOD_GENERATOR) \
-i $< -o $(@D) \
--additional-properties=generateInterfaces=true \
--additional-properties=GoSubmodule=true \
--additional-properties=packageName=$(@D) \
Related Content
- 2 years ago
- 5 years ago
Recent Discussions
- 4 days ago
- 26 days ago