Closed lsdch closed 1 month ago
The recent changes enhance schema generation and transformation functionalities. A new interface SchemaTransformer
was introduced in schema.go
, enabling types to modify their generated schemas. Corresponding tests were added to schema_test.go
to validate these transformations. Additionally, minor formatting adjustments were made in registry.go
.
Files | Change Summaries |
---|---|
registry.go |
Added a blank line after an if block within the Schema function of the mapRegistry type. |
schema.go |
Introduced SchemaTransformer interface to allow types to modify the generated schema. |
schema_test.go |
Updated schema definitions and transformations; added new structs ExampleInputStruct and ExampleUpdateStruct ; modified OmittableNullable[T] 's Schema method; added tests for schema transformations. |
sequenceDiagram
participant User
participant Registry
participant SchemaTransformer
participant Schema
User->>Registry: Request Schema for Type
Registry->>SchemaTransformer: Check if Type implements SchemaTransformer
alt Type implements SchemaTransformer
SchemaTransformer->>Schema: Transform Schema
end
Registry->>User: Return Schema
In the land of code, where schemas grow, A new transformer starts to show. With structs and tests, it leads the way, Making schemas bright and gay. A rabbit smiles, its work well done, For now, the code is full of fun! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 92.81%. Comparing base (
6019e80
) to head (83c94e5
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR introduces the
SchemaTransformer
interface which can be implemented to arbitrarily modify the schema for a type after it is generated (either as the default or by aSchemaProvider
).This allows leveraging the default generation and modify only parts of it, instead of explicitly defining a complete schema.
Example use case:
Admittedly, the same could be achieved by implementing
SchemaProvider
, but the implementation would be a bit messier.Summary by CodeRabbit
New Features
SchemaTransformer
interface for customizable schema transformations.null
values for properties.Bug Fixes
Tests