Skip to content

Commit

Permalink
(fix): Ensure wget is available in action (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbeaumont authored Jun 15, 2020
1 parent 6f195d4 commit 10b79f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* v0.0.5 - Explicitly install wget before attempting to download openapi generator jar
* v0.0.4 - Diff new package with old package and only publish if there are changes
* v0.0.3 - Use openapi-generator-cli@4.3.0 to fix ISO-8601 types previous generated as JavaScript Date objects.
* v0.0.2 - Use openapi-generator-cli@4.2.3; error handling in main script.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Hatch is a GitHub Action that uses [openapi-generator](https://github.com/OpenAPITools/openapi-generator) to automatically generate and publish a TypeScript-axios API client for your service, based on your service's OpenAPI spec.

### Usage
To use this Action, you will need:
To use this Action, you will need:
* An OpenAPI v3 spec of your service, which is accessible to the Action. Easiest might be to expose an endpoint that serves your service's OpenAPI spec
* A GitHub NPM registry and an access token to publish packages to it

Expand All @@ -17,7 +17,7 @@ generate-api-client:
runs-on: ubuntu-latest
steps:
- name: Run Hatch Action
uses: birdiecare/hatch@v0.0.1 # <-- use current version
uses: birdiecare/hatch@v0.0.5 # <-- use current version
with:
path: <e.g. https://staging.myservice.com/docs.json>
name: <Name of your service, e.g. my-service> # the generated client will automatically be called my-service-client
Expand All @@ -27,6 +27,6 @@ generate-api-client:
Running this Action will publish an NPM package called `my-service-client` as a package __inside the repository of the service running the Action__.

### Templating
[openapi-generator](https://github.com/OpenAPITools/openapi-generator) works by running a specified [code generator](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators.md) on an OpenAPI spec. Hatch uses [typescript-axios](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/typescript-axios.md) for this.
[openapi-generator](https://github.com/OpenAPITools/openapi-generator) works by running a specified [code generator](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators.md) on an OpenAPI spec. Hatch uses [typescript-axios](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/typescript-axios.md) for this.

The code generator generates an API client based on the OpenAPI spec using [Mustache](https://mustache.github.io) templates. These templates are shipped with the relevant code generator. The `/templates/openapi-generator/typescript-axios` folder of this repo houses the templates used by this Action. They are unchanged from the standard templates used by `typescript-axios`, but are included so that it is easy to make changes if your use case requires them.
4 changes: 2 additions & 2 deletions generate-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "Hatch action started."

echo "Downloading and installing prerequisites..."
apt-get update
apt-get -y install jq
apt-get -y install wget jq
wget --quiet https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.0/openapi-generator-cli-4.3.0.jar -O openapi-generator-cli.jar
if [ $? -ne 0 ]
then
Expand Down Expand Up @@ -83,7 +83,7 @@ elif [ $? -ne 1 ]
then
echo "ERROR: something went wrong comparing old to new package, aborting build."
exit 1
fi
fi

echo "Differences found between old and new package. Publishing new package..."
# copy package.json to dist folder and publish to GitHub package registry
Expand Down

0 comments on commit 10b79f5

Please sign in to comment.