go-openapi / spec

openapi specification object model
Apache License 2.0
394 stars 100 forks source link

WIP: Fix expand remote #137

Open fredbi opened 3 years ago

fredbi commented 3 years ago

circular $ref expansion: fixed edge cases

NOTE(1): uncovered pre-existing issue with nested schema ID involving cyclical references. This case remains unsupported and is illustrated by test case: circular_test.go#L198 ("withID")

NOTE(2): pre-existing issue with non-deterministic expansion remains unsolved, although the election of the replacing pointer inside the root document somewhat reduces the scope of this problem.

This case remains illustrated by a minimal test case: circular_test.go#L46 ("minimal"), which expands correctly, but with changing results.

NOTE(3): notice that expansion is still not an idempotent transform, in the presence of cyclical $ref's: another run on an expanded spec with remaining cyclical $ref will expand further down and detect again the cycle.

The result remains functionally correct, as illustrated by test case: circular_test.go#L168 ("CircularID"). Notice that this test case reproduces a validation fixture from jsonschema test (passed by go-openapi/validate).

Signed-off-by: Frederic BIDON fredbi@yahoo.com

codecov[bot] commented 3 years ago

Codecov Report

Merging #137 (e606f6b) into master (efe8fb3) will increase coverage by 0.90%. The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
+ Coverage   62.18%   63.08%   +0.90%     
==========================================
  Files          27       27              
  Lines        2052     2086      +34     
==========================================
+ Hits         1276     1316      +40     
+ Misses        605      592      -13     
- Partials      171      178       +7     
Impacted Files Coverage Δ
resolver.go 56.86% <0.00%> (ø)
expander.go 77.77% <79.16%> (-0.80%) :arrow_down:
schema_loader.go 89.41% <89.28%> (+1.17%) :arrow_up:
normalizer.go 85.71% <92.85%> (+2.13%) :arrow_up:
swagger.go 66.29% <0.00%> (+1.12%) :arrow_up:
ref.go 43.24% <0.00%> (+2.70%) :arrow_up:
parameter.go 22.64% <0.00%> (+3.77%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update efe8fb3...e606f6b. Read the comment docs.