Normalize relative ref paths to avoid duplicating schemas - #2105
Normalize relative ref paths to avoid duplicating schemas#2105ctreatma wants to merge 5 commits into
Conversation
6f1d634 to
18d5450
Compare
|
Just ran into this issue today. Glad to see a fix is on the way (hopefully soon). Thanks! |
d25dc19 to
e2fd955
Compare
e2fd955 to
8174b8f
Compare
|
I rebased on the latest from |
47a4931 to
26e34ae
Compare
929aacc to
74720bc
Compare
The semantic-release tool explicitly ignores the `.gitignore` file, which means that the automated release process will commit all files that are present in the local repo even if they are in the `.gitignore`. This updates the Metal codegen task to explicitly clean up the temporary merged spec. If swagger-api/swagger-parser#2105 gets merged and is included in an openapi-generator release before this SDK loses support for Metal, we can remove the temporary merged Metal spec.
74720bc to
adcfebb
Compare
adcfebb to
1cd8e74
Compare
1cd8e74 to
ddc074b
Compare
|
@MichakrawSB I see that this PR has been assigned to me but I'm not clear what needs to be done to move it forward. Is there something I need to address before the GitHub Actions workflows can be approved to run on this PR? |
ddc074b to
9a05a4b
Compare
|
Hi @ctreatma! Thank you for the PR :) Instead of using The original I expanded the regression tests to cover #2016, #1518, #1886, URI fragments, URL and file refs, invalid URI fallback, and a non-schema |
Currently, if an OpenAPI spec contains multiple relative $refs that resolve to the same external resource, but those refs reach that resource through different relative paths, swagger-parser may treat them as distinct references and create duplicate resolved components.
For example, given references such as:
From the spec root:
$ref: ./components/schemas/Thing.yamlFrom a file under components/paths:
$ref: ../../components/schemas/Thing.yamlboth references can ultimately identify the same
Thing.yamlresource, but their paths may contain different relative segments when they reach the resolver. The parser can therefore resolve the same schema more than once, producing components such asThingandThing_1instead of reusing Thing.This change normalizes URI references before they are used as keys by
ResolverCache. Equivalent paths containing . or .. segments therefore share the same resolution and external-file cache entries, while the original reference is still used when loading and deserializing the resource.Because normalization is performed in
ResolverCache, the behavior applies consistently to reference types resolved through the cache rather than being limited to schemas.Fixes #2016, fixes #1518.