-
-
Notifications
You must be signed in to change notification settings - Fork 1
Resolve URIs dynamically through prefix mapping. #8
Comments
I'd rather not go that direction. It feels like a hack. When you are working with schemas on the file system, the recommended approach is to not use Another option would be for me to provide a helper function that takes a path to a directory and adds all the schemas in that directory for you. That would be very easy to do. |
I can see your point, and I certainly respect your desire to avoid hacks. Let’s not pollute such a fine library. I could be wrong, but I have gathered that the main purpose of So registering the schemas with Still, in some cases, there will be situations where it might not be better to bundle all of the required schemas with the package we are building, and at the same time — especially when we are running our software delivery pipeline with multiple deployment stages — we may also not want to presume that blindly following the ID as a URL is going to give us the thing we need. Additionally, when the URI is a URN instead, there may actually be nothing to follow. There is a saying in software engineering, that every problem can be resolved with an extra level of indirection. I imagine that providing some way to plug in a URL/URN resolver could provide some useful power. This or some other form of strategy pattern, anyway. It seems that json-schema-bundle may already almost have such a thing built-in, as it resolves based on what has been registered, perhaps falling back to network retrieval (just guessing). Obviously, whatever you've already got going there would continue to be the default strategy. Anyway, it's just something to consider. Done making my case. :-) Thanks for chewing on it and supporting a great library. And the idea you proposed, for "mass registration," will also work just fine for my specific case. |
Yes, but that's only part of the story of schema identification. Loading schemas with |
I have a folder full of schema files, each defined with an
http
-based value for$id
. To facilitate loading them injson-schema-bundle
, it would be nice to have the option to specify how somehttp
URIs are resolved. For example, one could register that URIs beginning withhttp://domain/path
are resolved after mapping them tofile://path
. Then each schema to be bundled doesn't need to be individually registered withadd
.Is such a feature under consideration?
The text was updated successfully, but these errors were encountered: