You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add --read-only-write-only-model-type option for OpenAPI readOnly/writeOnly support (#2587)
* Add support for readOnly/writeOnly model generation strategy
* docs: update command help in README
🤖 Generated by GitHub Actions
* refactor: streamline readOnly/writeOnly resolution and model generation
* feat: enhance readOnly/writeOnly model handling and add related tests
* feat: implement readOnly/writeOnly model handling with Union type support and add related tests
* fix: improve deep copy handling in _copy_field method for DataModelFieldBase
* feat: update path parameter handling and add comprehensive tests for readOnly/writeOnly models
* feat: add readOnly/writeOnly model handling with allOf support and related tests
* feat: add test for readOnly/writeOnly with allOf in request-response mode and generate related model
* fix: improve reference resolution handling in _iter_fields_from_schema method
* fix: ensure field_key is not None before deduplicating fields in _collect_all_fields
* feat: enhance reference field iteration with visited tracking to prevent infinite recursion
* fix: handle unresolved references in allOf and skip None field keys during deduplication
* feat: update base model generation logic to support readOnly/writeOnly configurations and add related tests
* feat: implement readOnly/writeOnly flag resolution and update model generation logic
* fix: refactor source handling in field iteration to improve clarity and maintainability
* fix: simplify conditional logic in field iteration for improved readability
* refactor: streamline unique model name generation to avoid collisions
* feat: add deep copy functionality for DataModelFieldBase and enhance field iteration to include inherited fields
* refactor: remove redundant iter_all_fields method to simplify field iteration logic
* refactor: simplify readOnly and writeOnly resolution logic in JsonSchemaObject
* Refactor: simplify readOnly and writeOnly resolution logic in JsonSchemaObject
* Refactor: unify readOnly and writeOnly flag resolution logic and enhance field iteration
* Refactor: streamline field lookup logic in DataModel and TypedDict classes
* Add tests for readOnly/writeOnly detection in anyOf and oneOf compositions
* Refactor: remove duplicate inheritance in Parent class and enhance base class field resolution
* Add tests for readOnly/writeOnly behavior with shared base references and empty base classes
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
| API client validation |`request-response`|`UserRequest`, `UserResponse`|
298
+
| Database ORM mapping | (not set) |`User`|
299
+
| Both client & ORM |`all`|`User`, `UserRequest`, `UserResponse`|
300
+
301
+
### Behavior with allOf Inheritance
302
+
303
+
When using `allOf` with `$ref`, fields from all referenced schemas are flattened into Request/Response models:
304
+
305
+
```yaml
306
+
components:
307
+
schemas:
308
+
Timestamps:
309
+
type: object
310
+
properties:
311
+
created_at:
312
+
type: string
313
+
format: date-time
314
+
readOnly: true
315
+
316
+
User:
317
+
allOf:
318
+
- $ref: "#/components/schemas/Timestamps"
319
+
- type: object
320
+
properties:
321
+
name:
322
+
type: string
323
+
```
324
+
325
+
Generated `UserRequest` will exclude `created_at` (readOnly from Timestamps).
326
+
327
+
### Collision Handling
328
+
329
+
If a schema named `UserRequest` or `UserResponse` already exists, the generated model will be named `UserRequestModel` or `UserResponseModel` to avoid conflicts.
330
+
331
+
### Supported Output Formats
332
+
333
+
This option works with all output formats:
334
+
335
+
- `pydantic.BaseModel`/ `pydantic_v2.BaseModel`
336
+
- `dataclasses.dataclass`
337
+
- `typing.TypedDict`
338
+
- `msgspec.Struct`
339
+
340
+
### Supported $ref Types
341
+
342
+
readOnly/writeOnly resolution works with local and file reference types:
0 commit comments