-
Notifications
You must be signed in to change notification settings - Fork 5
Initial Release #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c603ce7
Initial draft/some testing
emann 9a7ba02
fixing the dockerfile name
emann 2cdf4df
Fixed Dockerfile name
emann 36dd511
Fixed typo
emann 4083a57
Fixed typo in dockerfile
emann f439b68
Copy entrypoint into image
emann 520970a
Fix typo
emann 7a85cab
Made entrypoint executable
emann a05c995
Added shebang to entrypoint
emann c53f056
Input is now actaully used
emann 77ba1bd
Attempt to fix file permissions issues
emann 8a0ebc5
Attempt #2 to fix file permission issues
emann de030e2
Trying changing user back to 1001
emann 5057a8b
Updated inputs and how they are handled
emann 83d187d
Debugging
emann c6d1b27
Fix formatting in entrypoint script
emann 70339fc
Switched to using pipx for running openapi-python-client
emann 2881de6
Trying to fix user permissions again
emann e20bca2
Cleaned up the entrypoint script a bit
emann 040c8b9
Added documentation/usages details to README
emann 209f171
Added a note about the "USER 1001" in the Dockerfile
emann b10f608
Apply suggestions from code review
emann 185351a
Added support for specifying a url instead of a file path for the ope…
emann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| FROM python:3.8 | ||
|
|
||
| RUN python -m pip install --upgrade pip | ||
| RUN pip install pipx | ||
|
|
||
| # Sets the user to the same user that the workflow runner uses so that it can access the generated client | ||
| USER 1001 | ||
|
|
||
| COPY entrypoint.sh /entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,51 @@ | ||
| # openapi-python-client-action | ||
| GitHub Action to generate a python client package from an openapi spec | ||
| The official GitHub Action for [openapi-python-client](https://github.com/triaxtec/openapi-python-client) - generates a modern Python client package from an OpenAPI document | ||
|
|
||
| ## Inputs | ||
|
|
||
| ### `openapi-python-client-version` | ||
|
|
||
| The version of the openapi-python-client package to use. If unspecified the latest released version will be used. | ||
|
|
||
| ### `openapi-file` | ||
|
|
||
| The path (with respect to the current directory/the workspace) to the OpenAPI document (both JSON and YAML are supported). Defaults to just "openapi.json" i.e. a file in the current directory called openapi.json. | ||
|
|
||
| ### `openapi-url` | ||
|
|
||
| The url of the OpenAPI document. Overrides `openapi-file` - If unspecified the value of the `openapi-file` input (which defaults to just `openapi.json`) will be used to generate the client. | ||
|
|
||
| ### `config-file` | ||
|
|
||
| The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/triaxtec/openapi-python-client#configuration) for available configuration | ||
|
|
||
| ## Outputs | ||
|
|
||
| No outputs are returned. | ||
| The generated client is placed in the current directory. The name of the package (unless configured differently) will be `title-client` where "title" comes from the field with the same name within the `info` section of the openapi document. | ||
|
|
||
| ## Example usage | ||
| ```yaml | ||
| jobs: | ||
| generate-python-client: | ||
| runs-on: ubuntu-latest | ||
| name: Example | ||
| steps: | ||
|
|
||
| # Checkout your code | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
|
|
||
| # Generate your openapi document (if you don't write it manually) | ||
|
|
||
| # Use the action to generate a client package | ||
| # This uses all defaults (latest version, openapi.json in the current workspace, no configuration) | ||
| - name: Generate Python Client | ||
| uses: triaxtec/openapi-python-client-action@v1 | ||
|
|
||
| # Do something with the generated client (likely publishing it somewhere) | ||
| # Here we assume that the info/title in the openapi document was "example-project" | ||
| - name: Do something with the client | ||
| run: | | ||
| cd example-project-client | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: "Generate A Python Client Package From An OpenAPI file" | ||
| description: "Generates a Python client package from an OpenAPI document using the openapi-python-client project" | ||
| branding: | ||
| icon: "target" | ||
| color: "green" | ||
|
|
||
| inputs: | ||
| openapi-python-client-version: | ||
| description: The version of openapi-python-client to use | ||
| required: false | ||
| default: NOT_SPECIFIED | ||
| openapi-file: | ||
| description: The path to the OpenAPI document to generate a client library for e.g. docs/openapi.json | ||
| required: false | ||
| default: openapi.json | ||
| openapi-url: | ||
| description: The url of the OpenAPI document to generate a client library for e.g. https://petstore3.swagger.io/api/v3/openapi.json | ||
| required: false | ||
| default: NOT_SPECIFIED | ||
| config-file: | ||
| description: Path to the config file to be passed along to openapi-python-client | ||
| required: false | ||
| default: NOT_SPECIFIED | ||
|
|
||
| runs: | ||
| using: "docker" | ||
| image: "Dockerfile" | ||
| args: | ||
| - ${{ inputs.openapi-python-client-version }} | ||
| - ${{ inputs.openapi-file }} | ||
| - ${{ inputs.openapi-url }} | ||
| - ${{ inputs.config-file }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
|
|
||
| openapi_python_client_version=$1 | ||
| openapi_file_path=$2 | ||
| openapi_url=$3 | ||
| config_file_path=$4 | ||
|
|
||
| if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then | ||
| version_arg="--spec openapi-python-client==${openapi_python_client_version}" | ||
| else | ||
| version_arg="" | ||
| fi | ||
|
|
||
| if [[ "$config_file_path" != "NOT_SPECIFIED" ]]; then | ||
| config_arg="--config ${config_file_path}" | ||
| else | ||
| config_arg="" | ||
| fi | ||
|
|
||
| openapi_document_path_or_url_arg="--path ${openapi_file_path}" | ||
| if [[ "$openapi_url" != "NOT_SPECIFIED" ]]; then | ||
| openapi_document_path_or_url_arg="--url ${openapi_url}" | ||
| fi | ||
|
|
||
| pipx run ${version_arg} openapi-python-client ${config_arg} generate ${openapi_document_path_or_url_arg} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the name that gets displayed in the marketplace? Or just in Actions when running?
If the first, this should be "openapi-python-client Action" or something. If the second, maybe just "Generate Python Client"?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former; My thinking was to make it a tad more search friendly (on the actions marketplace that is) so that its a bit discoverable + easy to get what it does just from reading the name. That seems to be the standard way of doing it based off of what I've seen in the marketplace - unless its a multipurpose/function action the name briefly tells you what it does. I think it could do with being shortened however - how do you feel about just "Generate Python Client From An OpenAPI File"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or "Generate Python Client from OpenAPI"?