Add static file infrastructure for generated clients#125
Open
dougborg wants to merge 2 commits intoMarcoMuellner:mainfrom
Open
Add static file infrastructure for generated clients#125dougborg wants to merge 2 commits intoMarcoMuellner:mainfrom
dougborg wants to merge 2 commits intoMarcoMuellner:mainfrom
Conversation
This commit adds the ability to include static Python files in generated clients, which is essential for implementing shared utilities and modules that don't need to be templated. Changes: - Add StaticFile model to represent static content - Extend ConversionResult to include static_files list - Create static_file_generator.py module (currently returns empty list) - Update write_data() to write static files to output directory - Add comprehensive tests for static file generation This infrastructure will be used for Issue MarcoMuellner#100 enhanced error handling: - errors.py: Exception hierarchy (APIError, ClientError, ServerError) - response.py: DetailedResponse wrapper with fluent API - utils.py: Helper functions (unwrap, expect, match, type guards) All tests passing. Ready for static file content in follow-up PRs. Related to MarcoMuellner#100
There was a problem hiding this comment.
Pull Request Overview
This PR establishes the foundational infrastructure for including static Python files (like shared utilities and exception classes) in generated API clients, preparing for the enhanced error handling feature described in issue #100.
- Adds
StaticFilemodel and integrates static file generation into the conversion pipeline - Implements file writing logic that places static files at the output root alongside
api_config.py - Provides comprehensive test coverage for static file generation and backwards compatibility
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/openapi_python_generator/models.py | Adds StaticFile model and extends ConversionResult with static_files field |
| src/openapi_python_generator/language_converters/python/static_file_generator.py | Creates new module with generate_static_files() function (currently returns empty list) |
| src/openapi_python_generator/language_converters/python/generator.py | Integrates static file generation into the conversion pipeline |
| src/openapi_python_generator/generate_data.py | Implements writing logic for static files to output directory |
| tests/test_static_files.py | Adds comprehensive tests for static file generation and backwards compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Oct 27, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds the foundational infrastructure for including static Python files in generated clients. This capability is essential for the enhanced error handling feature (#100) which requires shared utilities and exception classes.
Changes
Core Infrastructure
static_files: List[StaticFile]fieldTests
How It Works
Static files are:
generate_static_files()ConversionResultapi_config.py)Use Case: Issue #100
This infrastructure enables the enhanced error handling feature by allowing us to ship:
errors.py: Exception hierarchy (APIError, ClientError, ServerError)response.py: DetailedResponse wrapper with fluent APIutils.py: Helper functions (unwrap, expect, match, type guards)These modules will be shared across all generated services without requiring template generation.
Testing
✅ All existing tests pass (257 tests)
✅ New tests verify static file generation
✅ Backwards compatible (empty list by default)
✅ 95%+ code coverage maintained
Status
Related