-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
support multiple json files #11
Comments
Yes. It supports multiple files; however, you cannot refer to your local file system as in JSON schema spec, the $ref is a uri and it has to refer to a web url. You have the same limitation in swagger specification as well. The following is one of my test cases and it gives you an example on how to use remote $ref. Hope it helps. Thanks. |
Thanks. What I wanted was to load files relative to the main json file.
I hope you won't change this in the future, since this is very important to me. Good job on library |
Yes. That is the right syntax for file system reference. It won't be changed:) |
Hi there. I just started playing with this library today, and ran into the same issue. I can get it to work with the |
@henrik-io Could you please take a look at #45 and see if it works for you? There is an example to show you how to use it. Let me or @kenwa know if you have questions. Thanks. |
@henrik-io I see that the test case added in #45 only shows how to use the |
Hi there @stevehu and @kenwa, and thanks for the added test. This may be more of a JSON Schema newbie question, but I just can't seem to get this to work. I'm trying to validate an instance of the first schema, and I don't get any complaints from the validator, but when I run it in the debugger, it shows that it has no schema for the
URL schema:
Both schemas reside in my project under |
I finally figured it out by reading this excellent guide. So now each of my documents have an
and the
This seems to work great. Thanks again for the test case example, it definitely put me on the right track! |
@henrik-io I am glad that you figured it out. The detailed documentation about your solution is very helpful and I am sure others will find it very helpful. Thanks. |
I believe I struggled with a similar problem, and answering here for posterity. Perhaps some of this can be included in the documentation at some point in the future. First of all, it is worth being aware about the advice on how to use If you adopt a one file per schema approach, and match the First, I did include val localSchemaFetcher =
object : URIFetcher
{
private val uriFetcher = URLFetcher()
override fun fetch( uri: URI ): InputStream
{
if ( uri.host == "carp.cachet.dk" )
{
val localPath = uri.path.replaceFirst( "/", "" )
return uriFetcher.fetch( URI( "file:$localPath" ) )
}
return uriFetcher.fetch( uri )
}
}
val schemaFactory = JsonSchemaFactory.Builder()
.addMetaSchema( metaSchemaVersion )
.defaultMetaSchemaURI( metaSchemaVersion.uri )
.uriFetcher( localSchemaFetcher, "https" )
.build() In fact, if you follow this convention (and you also include the |
@Whathecode You have described a process I am following all the time to create big OpenAPI 3.0 specifications with tons of schemas. I also have a bundler to bundle all files into one openapi.yml for the light-codegen input. I am wondering if you could create a document in the doc folder with the content above. It will help lots of other users. Thanks. |
Does this library support multiple json files?
I'm having this schema:
and file2.json
and I'm getting this error:
On single json file it works. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: