Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,42 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# `disallowAdditionalPropertiesIfNotPresent: false` only covers schemas that
# omit additionalProperties. For an explicit `additionalProperties: false` the
# generator reads the OpenAPI 3.1 boolean schema inconsistently, so the
# `additional_properties` catch-all silently comes and goes between spec
# revisions. `true` has only one reading.
- name: Fetch and normalise OpenAPI spec
if: steps.version_check.outputs.should_generate == 'true'
run: |
curl -fsSL https://docs.reveng.ai/openapi.json -o openapi.json
python3 - <<'PY'
import json

with open("openapi.json") as f:
spec = json.load(f)

for schema in spec.get("components", {}).get("schemas", {}).values():
if not isinstance(schema, dict) or schema.get("additionalProperties") is not False:
continue
if schema.get("properties"):
schema["additionalProperties"] = True
else:
# Empty-body schemas stay bare, otherwise they generate as
# Dict[str, object] instead of object.
del schema["additionalProperties"]

with open("openapi.json", "w") as f:
json.dump(spec, f)
PY

- name: Generate Python SDK
if: steps.version_check.outputs.should_generate == 'true'
uses: openapi-generators/openapitools-generator-action@b729d184e6b3459572c37c0e37f88a832e69b552 # v1
with:
generator: python
generator-tag: 'v7.17.0'
openapi-url: https://docs.reveng.ai/openapi.json
openapi-file: openapi.json
config-file: config.yml
template-dir: templates
command-args: |
Expand All @@ -127,7 +156,7 @@ jobs:
rm -Rf docs && mv python-client/docs .
rm -Rf revengai && mv python-client/revengai .
rm -Rf README.md && mv python-client/README.md .
rm -Rf python-client
rm -Rf python-client openapi.json

# Store the SDK version
echo "$OPENAPI_VERSION" > .sdk-version
Expand Down
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
packageName: revengai
packageUrl: https://github.com/RevEngAI/sdk-python
generateSourceCodeOnly: false
# Allow unknown properties to avoid breaking when the API adds new fields, and we haven't updated the SDK yet
disallowAdditionalPropertiesIfNotPresent: false
# When an unknown enum value is found map to unknown_default_open_api
enumUnknownDefaultCase: true
globalProperties:
Expand Down
Loading