-
Notifications
You must be signed in to change notification settings - Fork 1
Better handle contentEncoding #69
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
Conversation
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.
Pull request overview
This pull request adds support for OpenAPI 3.1's contentEncoding and contentMediaType fields, enabling fine-grained control over how content-encoded string schemas map to Dart types.
Changes:
- Introduces a new
contentMediaTypesconfiguration mapping that allows users to specify whether schemas withcontentEncodingshould generateList<int>(binary) orString(text) properties - Adds the
contentSchemafield to the Schema model (part of OpenAPI 3.1 spec, currently unused but prepared for future implementation) - Changes default behavior: schemas with
contentEncodingnow default toList<int>(binary) instead ofString, with fallback configurable via the new config option
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tonik_core/lib/src/config/schema_content_type.dart | New enum defining binary/text types for schema content |
| packages/tonik_core/lib/src/config/tonik_config.dart | Adds contentMediaTypes field with equality/hashCode support |
| packages/tonik_core/lib/tonik_core.dart | Exports new SchemaContentType enum |
| packages/tonik_core/test/config/tonik_config_test.dart | Tests for contentMediaTypes configuration storage and equality |
| packages/tonik_parse/lib/src/model/schema.dart | Adds contentSchema field to Schema model |
| packages/tonik_parse/lib/src/model/schema.g.dart | Generated code for contentSchema deserialization |
| packages/tonik_parse/lib/src/model_importer.dart | Implements logic to resolve content-encoded models based on config |
| packages/tonik_parse/lib/src/importer.dart | Threads contentMediaTypes config to ModelImporter |
| packages/tonik_parse/test/model/model_binary_test.dart | Comprehensive tests for contentEncoding handling with and without config |
| packages/tonik_parse/test/model/single_schema_import_test.dart | Updates Schema instantiations to include contentSchema field |
| packages/tonik/lib/src/config/tonik_config.dart | Adds contentMediaTypes to CLI config with proper equality/hashCode |
| packages/tonik/lib/src/config/config_loader.dart | Implements YAML parsing for contentMediaTypes configuration |
| packages/tonik/test/src/config/config_loader_test.dart | Tests for loading and validating contentMediaTypes from YAML |
| packages/tonik/bin/tonik.dart | Passes contentMediaTypes from config to Importer |
| scripts/setup_integration_tests.sh | Adds --config flag for binary_models integration test |
| integration_test/binary_models/tonik.yaml | Configuration file mapping media types for integration tests |
| integration_test/binary_models/openapi.yaml | Adds comprehensive test schemas with various contentMediaType combinations |
| integration_test/binary_models/binary_models_test/test/content_media_type_test.dart | End-to-end tests validating generated code behavior |
| integration_test/binary_models/binary_models_test/imposter/response.groovy | Mock server responses for contentMediaType test endpoints |
| docs/data_types.md | Documents content-encoded strings and configuration usage |
| docs/configuration.md | Adds contentMediaTypes configuration section with examples |
| docs/roadmap.md | Removes contentEncoding/contentMediaType from roadmap (now implemented) |
| .vscode/settings.json | Adds "Millis" and "unconfigured" to spell check dictionary |
integration_test/binary_models/binary_models_test/test/content_media_type_test.dart
Outdated
Show resolved
Hide resolved
Co-authored-by: t-unit <366172+t-unit@users.noreply.github.com>
Clarify test comment about contentEncoding and bidirectional conversion
No description provided.