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

Allow calling Draft4Support.Enable() multiple times #11

Merged
merged 10 commits into from
Jul 8, 2024

Conversation

laurynasr
Copy link
Contributor

Second call to Draft4Support.Enable() was throwing

  Failed MultipleEnableDoesNotThrow [36 ms]
  Error Message:
   System.ArgumentException : Overriding known specification versions is not supported.
  Stack Trace:
     at Json.Schema.SchemaRegistry.RegisterNewSpecVersion(Uri metaSchemaUri, SpecVersion specVersion)
   at Graeae.Models.SchemaDraft4.Draft4Support.Enable() in D:\src\Graeae\Graeae.Models\SchemaDraft4\Draft4Support.cs:line 181
   at Graeae.Models.Tests.ApiTests.MultipleEnableDoesNotThrow() in D:\src\Graeae\Graeae.Models.Tests\ApiTests.cs:line 10

Copy link
Owner

@gregsdennis gregsdennis left a comment

Choose a reason for hiding this comment

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

I'm not sure this is the right direction. Draft4Support.Enable() is a bootstrapping call. It should only ever be called during application setup.

What's your use case?

@laurynasr
Copy link
Contributor Author

laurynasr commented Jul 5, 2024

We use it in multiple test fixtures that might be executed all at once or separately by filtering -- and initialization is per fixture, not per project. This is also something that worked in Graeae 0.2

Copy link
Owner

@gregsdennis gregsdennis left a comment

Choose a reason for hiding this comment

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

I don't like the idea of setting up production code just to facilitate tests, but I agree that this method should be safe to re-call.

Please add an entry in the RELEASE_NOTES.md file.

Graeae.Models/SchemaDraft4/Draft4Support.cs Outdated Show resolved Hide resolved
Comment on lines 167 to 168
("exclusiveMaximum", new [] { "maximum" }),
("exclusiveMinimum", new [] { "minimum" })
Copy link
Owner

Choose a reason for hiding this comment

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

remove unnecessary edit, please.

Graeae.Models.Tests/ApiTests.cs Outdated Show resolved Hide resolved
@gregsdennis gregsdennis merged commit d60081e into gregsdennis:main Jul 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants