Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR addresses the issue where unreachable! was triggered for valid JSON files containing top-level primitives (e.g., "hello", 123).

Changes:

  • Core: The Schema type was refactored from enum Schema { Object, Array } to struct Schema { ty: FieldType }, allowing it to represent any valid JSON type at the root.
  • Codegen (Rust): Updated to handle primitive roots by generating a simple type alias (e.g., pub type ROOT = String;).
  • Codegen (Java): Updated to handle primitive roots by generating a wrapper class (e.g., public static class ROOT { ... }) that uses Jackson annotations (@JsonValue, @JsonCreator) to serialize/deserialize correctly as a raw primitive.
  • Tests: Added top-level-*.json files to test-data covering string, integer, float, boolean, and null types.

Note: Codegen logic for Objects and Arrays remains largely unchanged, ensuring backward compatibility with existing structural schemas.


PR created automatically by Jules for task 16147890577533185797 started by @zahash

- Refactor `Schema` to wrap `FieldType` instead of being an enum restricted to Object/Array.
- Update `TypeGraph` to build from the new `Schema` structure.
- Update `codegen-rust` to generate type aliases for top-level primitives.
- Update `codegen-java` to generate wrapper classes with `@JsonValue` and `@JsonCreator` for top-level primitives.
- Add test cases for top-level string, int, float, bool, and null.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Refactor `Schema` to wrap `FieldType` instead of being an enum restricted to Object/Array.
- Update `TypeGraph` to build from the new `Schema` structure.
- Update `codegen-rust` to generate type aliases for top-level primitives.
- Update `codegen-java` to generate wrapper classes with `@JsonValue` and `@JsonCreator` for top-level primitives.
- Add test cases for top-level string, int, float, bool, and null.
- Refactor `Schema` to wrap `FieldType` instead of being an enum restricted to Object/Array.
- Update `TypeGraph` to build from the new `Schema` structure.
- Update `codegen-rust` to generate type aliases for top-level primitives.
- Update `codegen-java` to generate wrapper classes with `@JsonValue` and `@JsonCreator` for top-level primitives.
- Add test cases for top-level string, int, float, bool, and null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants