diff --git a/.github/workflows/generate-single-openapi-spec.yaml b/.github/workflows/generate-single-openapi-spec.yaml new file mode 100644 index 00000000..2fcb88b6 --- /dev/null +++ b/.github/workflows/generate-single-openapi-spec.yaml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 85e5b95a..53f5e522 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -generated/**/.openapi-generator* \ No newline at end of file +generated/configuration +generated/artifacts/*/.openapi-generator* \ No newline at end of file diff --git a/README.md b/README.md index 7bddb5e9..017effea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Onfido OpenAPI specification (beta) -:warning: Our OpenAPI specification is currently in beta and we welcome any feedback. You can contact us via the issues tab or [email](mailto:openapi-feedback@onfido.com), but we don't yet officially support this specification. :warning: +:warning: Our OpenAPI specification is currently in beta and we welcome any feedback. You can contact us via the issues tab or [support portal](https://public.support.onfido.com), but we don't yet officially support this specification. :warning: This specification supports the latest version of the Onfido API. diff --git a/generator/configuration/common.yaml b/generator/configuration/common.yaml new file mode 100644 index 00000000..0c8b60f2 --- /dev/null +++ b/generator/configuration/common.yaml @@ -0,0 +1,7 @@ +inputSpec: openapi.yaml +gitUserId: onfido +generatorName: ${GENERATOR} +templateDir: generator/templates/${GENERATOR} +outputDir: generated/artifacts/${GENERATOR} +useOneOfDiscriminatorLookup: true +disallowAdditionalPropertiesIfNotPresent: false \ No newline at end of file diff --git a/generator/configuration/openapi-yaml.yaml b/generator/configuration/openapi-yaml.yaml new file mode 100644 index 00000000..e69de29b diff --git a/generator/configuration/openapi.yaml b/generator/configuration/openapi.yaml new file mode 100644 index 00000000..e69de29b diff --git a/generator/script/generate.sh b/generator/script/generate.sh new file mode 100755 index 00000000..d9f68452 --- /dev/null +++ b/generator/script/generate.sh @@ -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} diff --git a/generator/templates/openapi-yaml/.openapi-generator-ignore b/generator/templates/openapi-yaml/.openapi-generator-ignore new file mode 120000 index 00000000..63b05560 --- /dev/null +++ b/generator/templates/openapi-yaml/.openapi-generator-ignore @@ -0,0 +1 @@ +../common/.openapi-generator-ignore \ No newline at end of file diff --git a/generator/templates/openapi/.openapi-generator-ignore b/generator/templates/openapi/.openapi-generator-ignore new file mode 120000 index 00000000..63b05560 --- /dev/null +++ b/generator/templates/openapi/.openapi-generator-ignore @@ -0,0 +1 @@ +../common/.openapi-generator-ignore \ No newline at end of file diff --git a/openapi.yaml b/openapi.yaml index 78758a45..1d0570ca 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -5,7 +5,7 @@ info: version: 3.6.0 contact: name: Onfido - email: engineering@onfido.com + url: https://public.support.onfido.com license: name: MIT servers: diff --git a/schemas/workflow_runs/definitions.yaml b/schemas/workflow_runs/definitions.yaml new file mode 100644 index 00000000..79b5606f --- /dev/null +++ b/schemas/workflow_runs/definitions.yaml @@ -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. diff --git a/schemas/workflow_runs/workflow_run_builder.yaml b/schemas/workflow_runs/workflow_run_builder.yaml new file mode 100644 index 00000000..718e7b68 --- /dev/null +++ b/schemas/workflow_runs/workflow_run_builder.yaml @@ -0,0 +1,6 @@ +required: + - workflow_id + - applicant_id +allOf: + - $ref: definitions.yaml#/workflow_run_shared + - $ref: definitions.yaml#/workflow_run_request \ No newline at end of file