APP_NAME := eia-api-go SCHEMA_JSON := schema/eia-api-oapi.json SCHEMA_DIR := schema GENERATED_DIR := generated # Default rule all: build # Retrieve and prepare the schema schema: mkdir -p $(SCHEMA_DIR) # if [ -f $(SCHEMA_JSON) ]; then rm -f $(SCHEMA_JSON); fi # curl -o $(SCHEMA_DIR)/eia-api-swagger.zip https://www.eia.gov/opendata/eia-api-swagger.zip # unzip -o $(SCHEMA_DIR)/eia-api-swagger.zip -d $(SCHEMA_DIR) # Generate the Go client using Swagger Codegen generate: schema mkdir -p $(GENERATED_DIR) docker run --rm \ -v ${PWD}:/local \ swaggerapi/swagger-codegen-cli-v3:latest generate \ -i /local/$(SCHEMA_JSON) \ -l go \ -o /local/$(GENERATED_DIR) # Build the application build: go build -o $(APP_NAME) # Install the application install: go install ./... # Clean generated code clean: rm -rf $(GENERATED_DIR) rm -rf $(SCHEMA_DIR) .PHONY: all schema generate build install clean