Fix #375: resolve nested external $ref and handle content-less responses - #380
Merged
jemacineiras merged 9 commits intoJul 23, 2026
Merged
Conversation
…able)
OpenAPI 3.1 / JSON Schema 2020-12 allows a schema's `type` to be an array,
e.g. type: ["string", "null"] (the nullable idiom that replaces 3.0's
`nullable: true`, and general unions). ApiTool.getType() read the type via
JsonNode.textValue(), which returns null for an array node and collapsed to
"", so every isObject/isArray/isString/isNumber/isDateTime predicate and
MapperUtil.getSimpleType failed -> the generator silently produced wrong or
empty types for those fields.
- ApiTool.getType: when `type` is an array, resolve to the first non-"null"
entry ("null" only marks the type as nullable). All the isX predicates and
getSimpleType then work unchanged for union/nullable types.
- MapperUtil.processNumber: read the type via ApiTool.getType instead of
schema.get("type").asText(), so array-valued numeric types resolve.
- Add TypeConstants.NULL.
- Add a 3.1.0 regression fixture (testOpenApi31Types) covering ["string",
"null"], ["integer","null"], ["number","null"]+double, int64 and a plain
array, with golden assets.
Bumps version 6.3.2 -> 6.4.0 across the engine, maven and gradle modules.
Non-array `type` handling is unchanged, so existing 3.0 specs are unaffected.
Follow-up 3.1 items (examples array, $ref siblings, webhooks) tracked in sngular#375.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gradle 9.x plugin validation fails the build when a task type is neither @CacheableTask nor @DisableCachingByDefault. OpenApiTask and AsyncApiTask are code generators whose spec-file inputs are not declared as cacheable inputs, so caching is disabled explicitly with a documented reason. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…d handle content-less responses
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 31 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…support # Conflicts: # multiapi-engine/pom.xml # multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ApiTool.java # multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java # multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorTest.java # scs-multiapi-gradle-plugin/build.gradle # scs-multiapi-maven-plugin/pom.xml
The annotation reason pushed the line to 121 chars, tripping Codacy's 120-char limit (2 new issues). Trim the wording; behaviour is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codacy flagged the Gradle task glue classes for "missing Javadoc" (the project does not use Javadoc) and generated test-resource fixtures for style rules that do not apply to generated code. Exclude both so the analysis only reports real, actionable issues. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jemacineiras
approved these changes
Jul 23, 2026
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.
Fixes two blocking bugs in the OpenAPI codegen:
Bug 1 — Nested external $ref resolution (FileNotFoundException)
SchemaUtil.solveRefalways resolved nested $ref files relative to the main spec directory, causing FileNotFoundException when an external schema file (e.g.schemas/Service.yml) referenced another external file via./ServiceType.yml.resolveNestedFileRefsnow recursively inlines nested file $ref content into the parent schema, resolving relative to the containing file's directory.computeFileSchemaKeynormalizes file-based ref values to clean schema-map keys.Bug 2 — Content-less response handling (NoSuchElementException)
MapperPathUtil.buildResponsecalledOptional.orElseThrow()on missing#-ref responses (204/401/403) and on external-file response $ref entries that were never loaded intoresponseMap.#-ref responses and catches load errors for external-file response $refs.processModelscan generate the corresponding model.Tests added
testNestedExternalRefs: verifies that$ref: ./ServiceType.ymlinside an external schema file is resolved correctly, generating the API interface and both model DTOs.testNoContentResponses: verifies that content-less 204/401/404 $ref responses do not crash the generator.