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

[json] schemas should be able to be validated starting at a given json property as the root #77883

Closed
baronfel opened this issue Jul 24, 2019 · 4 comments
Assignees
Labels
info-needed Issue requires more information from poster json JSON support issues

Comments

@baronfel
Copy link
Member

While writing ASP.Net Core applications, you typically have an appsettings.json file which is used to collect any sort of runtime configuration. This file is very open in terms of schema, and typically different areas of concern in the application will have relatively well-structured config underneath a particular 'parent' key, which serves as a namespace. Take for example the Serilog logging library. It looks for configuration under the "Serilog" key in this file, at which point everything else follows a schema. It would be nice somehow to map this schema to the key particularly.

@vscodebot vscodebot bot added the json JSON support issues label Jul 24, 2019
@aeschli
Copy link
Contributor

aeschli commented Jul 25, 2019

Please add an example for an appsettings.json file.

Can you add a schema for appsettings.json like that ?

{
   type: 'object',
   properties: {
      'Serilog': { "$ref': 'https://gist.github.com/turchenkoalex/ff9dc8443c3002eccf8df58020f82339' }
   }
}

@aeschli aeschli added the info-needed Issue requires more information from poster label Jul 25, 2019
@baronfel
Copy link
Member Author

That's hard to do because right now the appsetting.json file is a grab-bag, where any and all runtime settings (which can change based on which components/libraries you've added to your application) can live. There's a discussion about adding schema for the 'default' microsoft-provided properties at this issue though: dotnet/aspnetcore#2867.

While I could make a schema like that^ I think the larger question is how to do that and 'merge' the schemas if Microsoft ever did ship their official schema.

@aeschli
Copy link
Contributor

aeschli commented Jul 25, 2019

@baronfel
Copy link
Member Author

I didn't realize that multiple schemas were merged together! That covers most of the use case as far as I'm concerned then. Thank you for walking me through this.

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster json JSON support issues
Projects
None yet
Development

No branches or pull requests

2 participants