Duplicate Class Verification (Generated vs openai-java)
Use this skill to compare generated Java models against the openai-java dependency. The goal is field-by-field comparison of model shapes, even when class or field names differ.
Inputs to confirm
- Generated source root (e.g.,
src/main/java/...)
- The relevant
pom.xml (module) to resolve the openai-java dependency version
- Optional: package or class name hints to narrow the search
Steps
Locate the pom.xml in the current directory tree (find . -name pom.xml). If multiple, ask which module to use.
Resolve openai-java:
- Search the chosen pom for
openai-java (or an explicit group/artifact provided by the user).
- Resolve the version (including properties) and locate the JAR in
~/.m2/repository.
- The model classes live in
openai-java-core, not the top-level openai-java artifact.
List candidate classes:
- Generated classes: scan the source root for
class and record declarations.
- openai-java classes:
jar tf <jar> | grep '\.class$' (filter by package hints if provided).
Extract field signatures (names may differ; compare shape):
- Generated source:
- For
record, use the component list in the record declaration.
- For
class, extract non-static field declarations (type + count) and note any @JsonProperty names.
- Check
toJson/fromJson methods for the actual JSON keys used in serialization.
- openai-java JAR:
- Use
javap -classpath <jar> -p <FQCN> to list fields (ignore static, validated, hashCode$delegate, additionalProperties).
- Extract
@JsonProperty keys from the sources JAR (*-sources.jar) for JSON key comparison.
Compare shapes:
- Compare field count and field types (order-independent).
- Compare JSON keys from
@JsonProperty (openai-java) vs toJson/fromJson string literals (generated).
- Compare enum/union values when field types are enums or string unions.
- Follow type hierarchy:
BinaryData ↔ JsonValue (both represent untyped JSON), Map<String,BinaryData> ↔ Map<String,JsonValue>, Java enum ↔ Kotlin string enum.
Categorize results (do NOT treat all matches the same):
Actionable duplicates — standalone models not in any type hierarchy. These can potentially be suppressed and replaced with the openai-java equivalent. Examples: ComparisonFilter, Reasoning.
Structural equivalents — classes that produce identical JSON but participate in a discriminator hierarchy (e.g., extends Tool, extends TextResponseFormatConfiguration). The SDK's polymorphic serialization (Tool.fromJson() dispatches to FunctionTool.fromJson(), etc.) requires these to exist. They are NOT actionable duplicates. Examples: FunctionTool, FileSearchTool, ComputerUsePreviewTool.
Partial matches — classes with most fields matching but extra Azure-specific fields. Note the extra fields. Examples: CodeInterpreterTool (extra container), WebSearchTool (extra custom_search_configuration).
Report:
- Provide a table with: generated class → openai-java class, field count, matching fields, category.
- Clearly separate actionable duplicates from structural equivalents.
- For actionable duplicates, note whether
@@alternateType or @@access(internal) would be the right suppression mechanism (see dedup-openai skill).
Useful commands
List generated class names
rg -n "^(public\s+)?(final\s+)?(class|record)\s+" <generated_root>
Extract field lines from source (classes)
grep -E '^\s+private\s+' <file> | grep -v 'static\s'
Extract JSON keys from generated toJson/fromJson
grep -E 'jsonWriter\.write|"[a-z_]+"' <file> | grep -v '//'
Inspect fields in a JAR class
javap -classpath <jar> -p <fully.qualified.ClassName>
Extract @JsonProperty from openai-java sources JAR
jar xf <sources-jar> main/com/openai/models/<Class>.kt
grep '@JsonProperty' main/com/openai/models/<Class>.kt
Check if a class participates in a hierarchy
grep 'extends\s' <file> # If it extends Tool, TextResponseFormatConfiguration, etc. → structural
Notes
- Use
search-m2 if you need help locating the dependency version or JAR path.
- If the user provides only a vague class hint, narrow candidates by package or field count first.
- The openai-java classes are Kotlin and use Jackson; generated classes use azure-json (
JsonSerializable). Compare at the JSON wire level, not at the Java API level.
1---2name: dup-classes3description: Verify whether generated Java classes duplicate openai-java models by comparing fields/types (names may differ). Use when checking for duplicate model coverage.4metadata:5 source: https://skillmd.com/skills/azure-azure-sdk-for-java/dup-classes6---78# Duplicate Class Verification (Generated vs openai-java)910Use this skill to compare generated Java models against the `openai-java` dependency. The goal is **field-by-field** comparison of model shapes, even when class or field names differ.1112## Inputs to confirm13- Generated source root (e.g., `src/main/java/...`)14- The relevant `pom.xml` (module) to resolve the `openai-java` dependency version15- Optional: package or class name hints to narrow the search1617## Steps181. **Locate the pom.xml** in the current directory tree (`find . -name pom.xml`). If multiple, ask which module to use.192. **Resolve openai-java**:20 - Search the chosen pom for `openai-java` (or an explicit group/artifact provided by the user).21 - Resolve the version (including properties) and locate the JAR in `~/.m2/repository`.22 - The model classes live in `openai-java-core`, not the top-level `openai-java` artifact.233. **List candidate classes**:24 - Generated classes: scan the source root for `class` and `record` declarations.25 - openai-java classes: `jar tf <jar> | grep '\.class$'` (filter by package hints if provided).264. **Extract field signatures** (names may differ; compare shape):27 - **Generated source**:28 - For `record`, use the component list in the `record` declaration.29 - For `class`, extract non-static field declarations (type + count) and note any `@JsonProperty` names.30 - Check `toJson`/`fromJson` methods for the actual JSON keys used in serialization.31 - **openai-java JAR**:32 - Use `javap -classpath <jar> -p <FQCN>` to list fields (ignore `static`, `validated`, `hashCode$delegate`, `additionalProperties`).33 - Extract `@JsonProperty` keys from the sources JAR (`*-sources.jar`) for JSON key comparison.345. **Compare shapes**:35 - Compare **field count** and **field types** (order-independent).36 - Compare **JSON keys** from `@JsonProperty` (openai-java) vs `toJson`/`fromJson` string literals (generated).37 - Compare **enum/union values** when field types are enums or string unions.38 - Follow type hierarchy: `BinaryData` ↔ `JsonValue` (both represent untyped JSON), `Map<String,BinaryData>` ↔ `Map<String,JsonValue>`, Java enum ↔ Kotlin string enum.396. **Categorize results** (do NOT treat all matches the same):4041 **Actionable duplicates** — standalone models not in any type hierarchy. These can potentially be suppressed and replaced with the openai-java equivalent. Examples: `ComparisonFilter`, `Reasoning`.4243 **Structural equivalents** — classes that produce identical JSON but participate in a discriminator hierarchy (e.g., `extends Tool`, `extends TextResponseFormatConfiguration`). The SDK's polymorphic serialization (`Tool.fromJson()` dispatches to `FunctionTool.fromJson()`, etc.) requires these to exist. They are NOT actionable duplicates. Examples: `FunctionTool`, `FileSearchTool`, `ComputerUsePreviewTool`.4445 **Partial matches** — classes with most fields matching but extra Azure-specific fields. Note the extra fields. Examples: `CodeInterpreterTool` (extra `container`), `WebSearchTool` (extra `custom_search_configuration`).46477. **Report**:48 - Provide a table with: generated class → openai-java class, field count, matching fields, category.49 - Clearly separate actionable duplicates from structural equivalents.50 - For actionable duplicates, note whether `@@alternateType` or `@@access(internal)` would be the right suppression mechanism (see `dedup-openai` skill).5152## Useful commands5354### List generated class names55```bash56rg -n "^(public\s+)?(final\s+)?(class|record)\s+" <generated_root>57```5859### Extract field lines from source (classes)60```bash61grep -E '^\s+private\s+' <file> | grep -v 'static\s'62```6364### Extract JSON keys from generated toJson/fromJson65```bash66grep -E 'jsonWriter\.write|"[a-z_]+"' <file> | grep -v '//'67```6869### Inspect fields in a JAR class70```bash71javap -classpath <jar> -p <fully.qualified.ClassName>72```7374### Extract @JsonProperty from openai-java sources JAR75```bash76jar xf <sources-jar> main/com/openai/models/<Class>.kt77grep '@JsonProperty' main/com/openai/models/<Class>.kt78```7980### Check if a class participates in a hierarchy81```bash82grep 'extends\s' <file> # If it extends Tool, TextResponseFormatConfiguration, etc. → structural83```8485## Notes86- Use `search-m2` if you need help locating the dependency version or JAR path.87- If the user provides only a vague class hint, narrow candidates by package or field count first.88- The openai-java classes are Kotlin and use Jackson; generated classes use azure-json (`JsonSerializable`). Compare at the JSON wire level, not at the Java API level.