Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c2f11e9
fix(ci): correct 'file' to 'files' in Codecov action configuration
rhythmatician Jun 7, 2025
b81d2d3
Switch from Swagger to OpenAPI for SDK gen
rhythmatician Jun 7, 2025
a8f0141
Regenerate the SDK
rhythmatician Jun 7, 2025
43546d8
feat(ci): add OpenAPI spec validation step to CI workflow
rhythmatician Jun 7, 2025
69651fd
refactor(spec): remove unused models from API specification
rhythmatician Jun 7, 2025
a26eb19
fix: improve path parameter injection in OpenAPI spec
rhythmatician Jun 7, 2025
6c4d788
feat(tests): enhance SDK generation tests with unique operation ID ha…
rhythmatician Jun 7, 2025
494b8af
Regenerate SDK
rhythmatician Jun 7, 2025
4457775
chore: add .flake8 configuration for line length enforcement
rhythmatician Jun 7, 2025
e0d07e3
fix: update asset service record query parameters to be optional and …
rhythmatician Jun 7, 2025
bb3b422
feat: implement fix for multiple schema issues in OpenAPI specificati…
rhythmatician Jun 7, 2025
c226b86
docs: update SDK regeneration instructions and clarify use of fix_swa…
rhythmatician Jun 7, 2025
a715f7a
docs: enhance docstring in fix_swagger_spec.py for clarity on schema …
rhythmatician Jun 7, 2025
8a092ad
fix: ensure unique operationIds and apply schema fixes in patch_spec …
rhythmatician Jun 7, 2025
ea8eaf4
fix: update requirements to specify setuptools and pydantic versions,…
rhythmatician Jun 7, 2025
3e164c2
fix: add pydantic version specification to dependencies in pyproject.…
rhythmatician Jun 7, 2025
17cbca2
fix: correct formatting in setup.py by adjusting package declaration …
rhythmatician Jun 7, 2025
a3a8172
feat: Add exception handling and API response classes to the Qualer SDK
rhythmatician Jun 7, 2025
bf556c4
Revert "refactor(spec): remove unused models from API specification"
rhythmatician Jun 7, 2025
8ef7a43
Regenerate SDK
rhythmatician Jun 7, 2025
5055b98
fix: pin pydantic version to ensure compatibility across dependencies
rhythmatician Jun 7, 2025
ec07583
feat: Enhance SDK structure by creating custom __init__.py files and …
rhythmatician Jun 7, 2025
b9e48a4
fix: update Python version matrix in CI workflow to remove deprecated…
rhythmatician Jun 7, 2025
ca7c45d
fix: update Python version requirements to >=3.9 in setup and project…
rhythmatician Jun 7, 2025
4786032
feat: add pytest configuration and improve test setup paths for bette…
rhythmatician Jun 7, 2025
f034af8
refactor: remove outdated test_setup.py file to streamline testing pr…
rhythmatician Jun 7, 2025
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
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 127
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -42,14 +42,18 @@ jobs:
# Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src/qualer_sdk --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Validate OpenAPI spec
run: |
java -jar openapi-generator-cli.jar validate -i spec.json

- name: Test with pytest
run: |
pytest tests/ -v --cov=qualer_sdk --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
Expand Down
17 changes: 17 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,23 @@ twine upload dist/*

## 🔄 Development Workflow

### Regenerating the SDK

The SDK can be regenerated from the Qualer API's Swagger 2.0 specification:

```bash
python regenerate_sdk.py
```

The regeneration process consists of these steps:
1. Downloads the OpenAPI spec from the Qualer server
2. Patches the RecordType enum to support integer values
3. Applies fixes for multiple schema issues in the API specification using `fix_swagger_spec.py`
4. Regenerates the SDK using openapi-generator-cli
5. Post-processes the generated code (formatting, typing, etc.)

The `fix_swagger_spec.py` script specifically addresses an issue where multiple media types in the Swagger 2.0 "consumes" and "produces" arrays were causing "Multiple schemas found in the OAS 'content' section" warnings when converted to OpenAPI 3.0. The fix ensures only one media type is kept in each case.

### Feature Development

1. Create feature branch from `develop`:
Expand Down
85,038 changes: 85,038 additions & 0 deletions Python.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ If you need to update or regenerate the SDK based on a new specification:
python regenerate_sdk.py
```

This script uses the [swagger-codegen-cli-2.4.21.jar](swagger-codegen-cli-2.4.21.jar) along with [spec.json](spec.json).
This script uses the [openapi-generator-cli.jar](openapi-generator-cli.jar) along with [spec.json](spec.json). It also employs the [fix_swagger_spec.py](fix_swagger_spec.py) script to resolve issues with multiple content types in the OpenAPI specification, which can cause warnings during SDK generation.

## Running Tests

Expand Down
57 changes: 57 additions & 0 deletions fix_swagger_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Script to fix the multiple schema issues in the OpenAPI specification
import json
import sys


def fix_swagger_spec(input_file, output_file):
"""Fix multiple schema issues in Swagger 2.0 spec.

When converting Swagger 2.0 to OpenAPI 3.0, multiple media types in "consumes"
and "produces" arrays get transformed into 'content' objects with multiple schemas.
This causes warnings like "Multiple schemas found in the OAS 'content' section,
returning only the first one" during SDK generation.

This function resolves the issue by keeping only the first content type in each
consumes/produces array, ensuring consistent behavior when the generator transforms
the spec to OpenAPI 3.0.

Args:
input_file: Path to the input Swagger 2.0 specification file
output_file: Path where the fixed specification will be saved
"""
with open(input_file, "r", encoding="utf-8") as f:
spec = json.load(f)

# When converting Swagger 2.0 to OpenAPI 3.0, the 'consumes' and 'produces' arrays
# get transformed into 'content' objects with multiple media types.
# Let's ensure consistent behavior by keeping only the first content type

# Global consumes/produces
if "consumes" in spec and len(spec["consumes"]) > 1:
spec["consumes"] = [spec["consumes"][0]] # Keep only the first content type

if "produces" in spec and len(spec["produces"]) > 1:
spec["produces"] = [spec["produces"][0]] # Keep only the first content type

# For each path and operation
for path_key, path_item in spec.get("paths", {}).items():
for method, operation in path_item.items():
if method in ["get", "post", "put", "delete", "patch", "options", "head"]:
if "consumes" in operation and len(operation["consumes"]) > 1:
operation["consumes"] = [operation["consumes"][0]]
if "produces" in operation and len(operation["produces"]) > 1:
operation["produces"] = [operation["produces"][0]]

# Write the fixed specification
with open(output_file, "w", encoding="utf-8") as f:
json.dump(spec, f, indent=2)

print(f"Fixed specification written to {output_file}")


if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <input_file> <output_file>")
sys.exit(1)

fix_swagger_spec(sys.argv[1], sys.argv[2])
Binary file added openapi-generator-cli.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "qualer-sdk"
version = "2.2.1"
description = "Auto-generated Python client for Qualer API"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = { text = "MIT" }
authors = [
{name = "Johnson Gage & Inspection Inc.", email = "jhall@jgiquality.com"}
Expand All @@ -17,8 +17,6 @@ classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -33,6 +31,7 @@ dependencies = [
"six>=1.10",
"certifi",
"python-dateutil",
"pydantic>=2.11.0,<2.12.0",
]

[project.optional-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
pythonpath = .
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = -v --tb=short
Loading