Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible approach to support schemas nested in non-schema docs #360

Merged
merged 2 commits into from
Feb 27, 2023

Conversation

gregsdennis
Copy link
Collaborator

@gregsdennis gregsdennis commented Dec 17, 2022

Resolves #355
Relates to microsoft/OpenAPI.NET#795

There are some comments in the code, but basically the SchemaRegistry now tracks IBaseDocuments instead of just JsonSchemas. The OpenApiDoc (or whatever it'll be called) will need to:

  • implement IBaseDocument
  • register itself under a base URI
  • perform an initialization scan to discover the schemas it contains
  • set the document's base URI on every contained schema

It's a bit hacked together right now, but it works.

@github-actions
Copy link

github-actions bot commented Dec 17, 2022

Unit Test Results

     10 files  ±0       10 suites  ±0   4s ⏱️ -1s
1 074 tests +1  1 062 ✔️ +1  12 💤 ±0  0 ±0 
1 391 runs  +1  1 379 ✔️ +1  12 💤 ±0  0 ±0 

Results for commit bb3ea1b. ± Comparison against base commit 92743fd.

♻️ This comment has been updated with latest results.

@@ -55,11 +55,15 @@ public void Evaluate(EvaluationContext context)
if (scopeRoot == null)
throw new Exception("This shouldn't happen");

if (scopeRoot.RecursiveAnchor == null) continue;
if (scopeRoot is not JsonSchema schemaRoot)
throw new Exception("Does OpenAPI use anchors?");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is entire relevant here since $recursiveRef is exclusively 2019-09.

@darrelmiller
Copy link

Maggie and I discussed this today. This looks like an approach that would work for us. We will do some more investigation on our side.

@gregsdennis
Copy link
Collaborator Author

I think this is going to be a good addition to the library, so I'm going to go ahead and incorporate it into the beta.

@gregsdennis gregsdennis changed the base branch from master to schema/4beta3 February 26, 2023 21:47
@gregsdennis gregsdennis marked this pull request as ready for review February 26, 2023 21:47
@gregsdennis gregsdennis mentioned this pull request Feb 27, 2023
@gregsdennis gregsdennis merged commit f141d10 into schema/4beta3 Feb 27, 2023
@gregsdennis gregsdennis deleted the schema/reference-resolution branch February 27, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reference non-schema document root
2 participants