Skip to content

Conversation

czechboy0
Copy link
Contributor

Motivation

The runtime changes to address apple/swift-openapi-generator#275.

This makes debugging of decoding of oneOf/anyOf much easier, as the individual errors aren't dropped on the floor anymore.

Modifications

Added SPI that allows the generated code to collect and report partial errors when a oneOf/anyOf fails to decode (that includes trying multiple subschemas, which themselves emit errors when they're not the right match).

Result

Easier debugging of oneOf/anyOf decoding issues.

Test Plan

Tested manually as part of the generator changes, we don't generally test exact error strings.

@czechboy0
Copy link
Contributor Author

API breakage is red with:

1 breaking change detected in OpenAPIRuntime:
💔 API breakage: func DecodingError.verifyAtLeastOneSchemaIsNotNil(_:type:codingPath:) is now with @_spi
** ERROR: ❌ Breaking API changes detected.

This method was never meant to be API, it was (by mistake) missing the SPI annotation, so adding that here. While it's technically an API-break, nobody should have been using this method.

@czechboy0 czechboy0 merged commit a51b3bd into apple:main Oct 30, 2023
@czechboy0 czechboy0 deleted the hd-oneOf-anyOf-decoding-include-partial-errors branch October 30, 2023 15:44
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Oct 30, 2023
czechboy0 added a commit to apple/swift-openapi-generator that referenced this pull request Oct 30, 2023
[Generator] Include partial errors in oneOf/anyOf decoding errors

### Motivation

Fixes #275.

Depends on apple/swift-openapi-runtime#66.

### Modifications

Adapt the generator to emit code that collects individual errors during oneOf/anyOf decoding and includes them in the final error.

### Result

Easier debugging of oneOf/anyOf decoding issues.

### Test Plan

Adapted tests and verified that the errors look better now and include the partial errors.


Reviewed by: simonjbeaumont

Builds:
     ✔︎ pull request validation (5.10) - Build finished. 
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (compatibility test) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants