-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add github action to generate single API spec #43
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
66eefa3
Add github action to generate single API spec
dvacca-onfido 0a25c96
Fix env
dvacca-onfido 5664e40
Add missing files
dvacca-onfido afdaf39
Call git commands to commit changes
dvacca-onfido 5c86ad1
Update contact details
dvacca-onfido e83b112
Validate single-file Onfido OpenAPI specification
dvacca-onfido 0a7f1de
Try
dvacca-onfido ecbf6fd
Try 2
dvacca-onfido 568f8e4
Changes after code review
dvacca-onfido c08c06f
Add push action
dvacca-onfido 87ed4b9
Try 3
dvacca-onfido c63f0ae
Re-add git push
dvacca-onfido 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 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,59 @@ | ||
name: generate-single-openapi-spec | ||
run-name: Build and publish single-file OpenAPI specs | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
build-single-spec: | ||
name: Build single-file OpenAPI specifications | ||
runs-on: ubuntu-latest | ||
container: | ||
image: openapitools/openapi-generator-cli:v7.3.0 | ||
env: | ||
OPENAPI_GENERATOR_COMMAND: docker-entrypoint.sh | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install pre-requisites | ||
run: | | ||
apt-get update | ||
apt-get install -yqq \ | ||
gettext-base | ||
- name: Validate multi-file OpenAPI specification | ||
run: | | ||
$OPENAPI_GENERATOR_COMMAND validate -i openapi.yaml | ||
- name: Refresh single-file OpenAPI specifications | ||
run: | | ||
./generator/script/generate.sh \ | ||
generator/configuration/openapi.yaml \ | ||
generator/configuration/openapi-yaml.yaml | ||
- name: Store generated artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | ||
path: generated/artifacts | ||
commit-single-spec: | ||
name: Commit and push single-file OpenAPI specifications | ||
runs-on: ubuntu-latest | ||
needs: build-single-spec | ||
if: ${{ github.event.pull_request.merged && github.repository == 'onfido/onfido-openapi-spec' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | ||
path: generated/artifacts | ||
- name: Commit and push single-file OpenAPI specifications | ||
run: | | ||
git --version | ||
if [ -z "$(git status --porcelain=v1 generated/artifacts)" ]; | ||
then | ||
echo "no change detected" | ||
else | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<>" | ||
git status generated/artifacts | ||
git commit -m "Single file specifications refresh" generated/artifacts | ||
git push | ||
fi |
This file contains 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 +1,2 @@ | ||
generated/**/.openapi-generator* | ||
generated/configuration | ||
generated/artifacts/*/.openapi-generator* |
This file contains 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
This file contains 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,7 @@ | ||
inputSpec: openapi.yaml | ||
gitUserId: onfido | ||
generatorName: ${GENERATOR} | ||
templateDir: generator/templates/${GENERATOR} | ||
outputDir: generated/artifacts/${GENERATOR} | ||
useOneOfDiscriminatorLookup: true | ||
disallowAdditionalPropertiesIfNotPresent: false |
Empty file.
Empty file.
This file contains 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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Don't carry on when any command fails | ||
set -e | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
BASEDIR=${SCRIPT_DIR}/../.. | ||
|
||
CONFIG_FILES=${*:-`ls generator/configuration/*.yaml`} | ||
GENERATED_CONFIG_FILES="" | ||
|
||
OPENAPI_GENERATOR_COMMAND=${OPENAPI_GENERATOR_COMMAND:-\ | ||
docker run --rm -v "$(pwd):/local" -w /local \ | ||
openapitools/openapi-generator-cli:v7.3.0} | ||
|
||
cd ${BASEDIR} | ||
rm -rf generated; mkdir -p generated/configuration | ||
|
||
for CONFIG_FILE in $CONFIG_FILES | ||
do | ||
GENERATOR=$(basename $CONFIG_FILE .yaml) | ||
|
||
if [ "${GENERATOR}" != "common" ]; | ||
then | ||
GENERATED_CONFIG_FILE=generated/configuration/${GENERATOR}.yaml | ||
|
||
( cat generator/configuration/common.yaml && echo && | ||
cat generator/configuration/${GENERATOR}.yaml ) | \ | ||
GENERATOR=${GENERATOR} envsubst >| \ | ||
${GENERATED_CONFIG_FILE} | ||
|
||
echo "Configuration for generator ${GENERATOR} built." | ||
|
||
GENERATED_CONFIG_FILES="${GENERATED_CONFIG_FILES} ${GENERATED_CONFIG_FILE}" | ||
fi | ||
done | ||
|
||
${OPENAPI_GENERATOR_COMMAND} batch --clean ${GENERATED_CONFIG_FILES} |
This file contains 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 @@ | ||
../common/.openapi-generator-ignore |
This file contains 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 @@ | ||
../common/.openapi-generator-ignore |
This file contains 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
This file contains 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,104 @@ | ||
workflow_run_shared: | ||
type: object | ||
properties: | ||
applicant_id: | ||
type: string | ||
description: The unique identifier for the Applicant. | ||
workflow_id: | ||
type: string | ||
description: The unique identifier for the Workflow. | ||
tags: | ||
type: array | ||
maxItems: 30 | ||
description: Tags or labels assigned to the workflow run. | ||
uniqueItems: true | ||
items: | ||
type: string | ||
minLength: 1 | ||
maxLength: 128 | ||
link: | ||
type: object | ||
description: Object for the configuration of the Workflow Run link. | ||
properties: | ||
url: | ||
type: string | ||
description: Link to access the Workflow Run without the need to integrate with Onfido's SDKs. | ||
completed_redirect_url: | ||
type: string | ||
description: When the interactive section of the Workflow Run has completed successfully, the user will be redirected to this URL instead of seeing the default Onfido 'thank you' page. | ||
expired_redirect_url: | ||
type: string | ||
description: When the link has expired, the user will be immediately redirected to this URL instead of seeing the default Onfido error message. | ||
expires_at: | ||
type: string | ||
format: date-time | ||
description: Date and time when the link will expire. | ||
language: | ||
type: string | ||
enum: | ||
- en_US | ||
- de_DE | ||
- es_ES | ||
- fr_FR | ||
- it_IT | ||
- pt_PT | ||
- nl_NL | ||
description: The code for the language when the workflow run is acessed using the link. | ||
created_at: | ||
type: string | ||
format: date-time | ||
description: The date and time when the Workflow Run was created. | ||
updated_at: | ||
type: string | ||
format: date-time | ||
description: The date and time when the Workflow Run was last updated. | ||
|
||
workflow_run_request: | ||
type: object | ||
properties: | ||
custom_data: | ||
type: object | ||
additionalProperties: true | ||
description: Object with Custom Input Data to be used in the Workflow Run. | ||
|
||
workflow_run_response: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
description: The unique identifier for the Workflow Run. | ||
workflow_version_id: | ||
type: integer | ||
description: The identifier for the Workflow version. | ||
dashboard_url: | ||
type: string | ||
description: The URL for viewing the Workflow Run results on your Onfido Dashboard. | ||
status: | ||
type: string | ||
enum: | ||
- awaiting_input | ||
- processing | ||
- abandoned | ||
- error | ||
- approved | ||
- review | ||
- declined | ||
description: The status of the Workflow Run. | ||
output: | ||
type: object | ||
description: Output object contains all of the properties configured on the Workflow version. | ||
reasons: | ||
type: array | ||
description: The reasons the Workflow Run outcome was reached. Configurable when creating the Workflow version. | ||
items: | ||
type: string | ||
error: | ||
type: object | ||
description: Error object. Only set when the Workflow Run status is 'error'. | ||
properties: | ||
type: | ||
type: string | ||
description: The type of error. | ||
message: | ||
type: string | ||
description: A textual description of the error. |
This file contains 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,6 @@ | ||
required: | ||
- workflow_id | ||
- applicant_id | ||
allOf: | ||
- $ref: definitions.yaml#/workflow_run_shared | ||
- $ref: definitions.yaml#/workflow_run_request |
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.
Should we consider that the spec is out of beta since we have all the reports ?
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.
I believe we should wait a little bit longer, to have at least one (generated) client library sufficiently tested to be definition maps quite well the actual API.