Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java">
<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java:45">
P3: This test is named for preserving other type constraints, but it only asserts that `x-typescript-primitive-type` is absent. Also assert the model's generated type or enum/const values so the test fails if those schemas are broken.</violation>
</file>
<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java">
<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java:2295">
P2: `ModelUtils.hasValidation` does not check `contains`, so a type-less schema carrying that constraint still passes this guard and is replaced by an empty schema, dropping the constraint. Include `contains` and the other applicable validation keywords in the check.</violation>
</file>
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 9 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI disclosure — Codex, GPT-6 Astra (High)
Codex investigated the normalizer and Axios generator, implemented this change, wrote the standalone fixtures and regression tests, ran the local checks below, and drafted this PR. I supplied the problem, requested a separate upstream fix, and asked for alignment with the project's contribution requirements.
The work included reproducing the failure against current master, preserving schema constraints during normalization, checking genuine nullability and nullable references, and compiling and exercising the generated SDK. The fixtures use synthetic schemas.
The local Maven build/tests, sample regeneration, documentation export, and SDK checks below completed. See the current PR checks for upstream CI status. TypeScript aliases preserve the primitive types; they do not perform runtime pattern or range validation.
Description
Closes #25637. This branch starts from master and is independent of #25636.
For a schema such as:
typescript-axiosgenerates an emptyHostnameinterface and makes references to it nullable. SDK methods consequently accept numbers and null, and a returned hostname cannot be used as a string.After this change, the model is
export type Hostname = string, and a required non-nullable property ishostname: Hostname. Schemas that explicitly allow null retain it. Numeric validation alternatives likewise retain the enclosing numeric type.Changes
containsout of null-schema detection. Reuse the existing metadata-only schema predicate to avoid discarding structural constraints during OpenAPI 3.1 normalization.oneOfcleanup. Axios uses the same primitive-alias path for theseoneOfandanyOfschemas, in both combined and separate output, so retaining the predicates does not produceany.anyOfparents.allOfwrappers used for nullable references. The OAS alternatives remain intact.Consumers that relied on the incorrect number/null assignments will now get TypeScript errors. Existing model names are retained.
Validation
df804ac9802fba0c51a64f8c3cb03191ed3dde2d. The released 7.27.0 CLI reproduces the same empty-interface and nullable-property output.oneOf, annotation-only alternatives,contains, inline properties and nullable$refwrappers. Untyped enum/const alternatives are retained, while genuinely null-only enum alternatives still simplify correctly. The fallback guard test also checks the model's enum values.clean packageand finalpackageruns pass with JDK 21 and-Dmaven.javadoc.skip=true. The final run reports 5,897 tests, zero failures/errors and 18 skipped.PR checklist
./mvnw clean package -Dmaven.javadoc.skip=truecheck../bin/generate-samples.sh ./bin/configs/*.yamland verify the diff../bin/utils/export_docs_generators.shand verify the diff.Summary by cubic
Fixes #25637. For schemas with a primitive type and validation-only
anyOf/oneOfbranches (pattern, range, length, etc.),typescript-axiosnow preserves the primitive type instead of generating an empty interface.Hostnamewithtype: stringand pattern-only branches now generatesexport type Hostname = string, and required non-nullable properties are typedHostnamerather than nullable. Schemas that explicitly allow null keep it, and numeric validation alternatives keep the enclosing number type. Code that relied on the previous number/null assignments will now get TypeScript errors.Changes
anyOfparents are normalized to nullable.allOfwrappers used for nullable references.Written for commit a6cd4e4. Summary will update on new commits.