Skip to content

Conversation

@simbo1905
Copy link
Owner

Summary

  • add ITJsonSchemaExhaustiveTest property-based integration test that exercises exhaustive schema/document permutations
  • implement sealed-schema generators, compliant document builders, and negative case creation with JUL logging for traceability
  • register a jqwik ArbitraryProvider to drive exhaustive GenerationMode coverage

Testing

  • ./mvnw -pl json-java21-schema verify -Djava.util.logging.ConsoleHandler.level=INFO (fails: network unreachable while downloading maven-source-plugin)

https://chatgpt.com/codex/tasks/task_b_68d07992607083279c1bf53528bcf4a1

@openhands-ai
Copy link

openhands-ai bot commented Sep 21, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • CI
    • Java CI with Maven
    • CI

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #47 at branch `codex/add-exhaustive-json-schema-test`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

1 similar comment
@openhands-ai
Copy link

openhands-ai bot commented Sep 21, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • CI
    • Java CI with Maven
    • CI

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #47 at branch `codex/add-exhaustive-json-schema-test`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Copy link

Copilot AI left a 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 PR adds a comprehensive property-based integration test for JSON schema validation using jqwik's exhaustive generation mode. The test systematically validates schema compilation, compliant document generation, and negative test case creation to ensure robust schema validation behavior.

Key changes:

  • Implements exhaustive property-based testing with sealed schema types and document builders
  • Creates negative test cases by systematically breaking compliant documents
  • Adds custom jqwik ArbitraryProvider for comprehensive schema generation coverage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +179 to +180
schemaMap.put("minItems", JsonNumber.of((long) items.size()));
schemaMap.put("maxItems", JsonNumber.of((long) items.size()));
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to long is repeated for both minItems and maxItems. Consider extracting (long) items.size() into a local variable to reduce duplication and improve readability.

Suggested change
schemaMap.put("minItems", JsonNumber.of((long) items.size()));
schemaMap.put("maxItems", JsonNumber.of((long) items.size()));
long itemsSize = (long) items.size();
schemaMap.put("minItems", JsonNumber.of(itemsSize));
schemaMap.put("maxItems", JsonNumber.of(itemsSize));

Copilot uses AI. Check for mistakes.
Comment on lines +254 to +257
).as((names, first, second) -> new ObjectSchema(List.of(
new Property(names.getFirst(), first),
new Property(names.getLast(), second)
)));
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using getFirst() and getLast() assumes the PROPERTY_PAIRS list always contains exactly 2 elements. This creates a fragile dependency on the list structure. Consider using indexed access names.get(0) and names.get(1) or add validation to ensure the list size is exactly 2.

Suggested change
).as((names, first, second) -> new ObjectSchema(List.of(
new Property(names.getFirst(), first),
new Property(names.getLast(), second)
)));
).as((names, first, second) -> {
if (names.size() != 2) {
throw new IllegalArgumentException("Expected names list of size 2, got " + names.size());
}
return new ObjectSchema(List.of(
new Property(names.get(0), first),
new Property(names.get(1), second)
));
});

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +276 to +303
sealed interface JsonSchema permits ObjectSchema, ArraySchema, StringSchema, NumberSchema, BooleanSchema, NullSchema {
record ObjectSchema(List<Property> properties) implements JsonSchema {
ObjectSchema {
properties = List.copyOf(properties);
}
}

record Property(String name, JsonSchema schema) {
Property {
name = Objects.requireNonNull(name);
schema = Objects.requireNonNull(schema);
}
}

record ArraySchema(List<JsonSchema> items) implements JsonSchema {
ArraySchema {
items = List.copyOf(items);
}
}

record StringSchema() implements JsonSchema {}

record NumberSchema() implements JsonSchema {}

record BooleanSchema() implements JsonSchema {}

record NullSchema() implements JsonSchema {}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] Nested schema records declared inside interface do not compile

The helper schema types are declared as records inside the nested JsonSchema interface, but the rest of this test refers to them as if they were top‑level members (new ObjectSchema(...), pattern matching, permits ObjectSchema). Because nested interface members must be referenced with their enclosing type, ObjectSchema and friends need to be named JsonSchema.ObjectSchema (and the permits clause must use the same qualified names). As written the file does not compile, so the test suite cannot run.

Useful? React with 👍 / 👎.

@simbo1905 simbo1905 closed this Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants