I created the JSON Schema path on my localhost. Copied the Swagger-UI module. Added the url in the Swagger-UI. I am getting this error that model not found. This is very strange because the JSON has all the models associated to the JSON Schema.
Why does it try to look for something like:
http://localhost:8080/OpenClaimRequest rather looking into the definitions in JSON itself?
JS Console Error Log
I was using Swagger-UI 3.x version where as my API spec version was 1.2
API Spec 1.2 is compatible with Swagger-UI 2.x not any version higher than that.
Related
I'm running a Spring Boot REST application with Spring HATEOAS support and generating OpenAPIv3 docs with the Springdoc Maven plugin. However when I call my REST endpoints I get links the in HAL formatted JSON ("_links"). But the generated OpenAPIv3 documentation is giving me a different format for the links ("links").
How can I get the generated OpenAPIv3 docs to match the HAL formatted links?
The only resource I've found is this link: https://github.com/springdoc/springdoc-openapi/issues/446
However, the solution given there involves using spring-data-rest which I am not using (do I need to?)
I've also tried adding #EnableHyperMediaSupport which says it configures the JSON rendering, but that had no effect on the OpenAPIv3 docs.
The answer was simple enough, I needed to pull in the springdoc-openapi-hateoas dependency (https://springdoc.org/#spring-hateoas-support). After pulling this in the JSON documentation was generated correctly with no additional configuration (I did not need #EnableHypermediaSupport or spring-data-rest).
However, if you are using the Swagger UI be aware that it will automatically generate bogus 'additionalProperty' links as an example for the resource schema. This is only in the Swagger UI, if you look at the generated openapiv3 json the structure is correct (cf: https://github.com/springdoc/springdoc-openapi/issues/237). To remedy this you can provide your own example of the resource schema.
Previously I was using .Net Core 2.2, I was able to send a json object from a service class using hub context and SendAsync method to a front end web client. Im having issues after I've upgraded my project framework to 3.1. If i call the SendAsync method using a json object, it will hit an error stating "{"The collection type 'Newtonsoft.Json.Linq.JObject' is not supported."}", if I send any other class object it will directly go to OnDisconnected.
Sample of the method i use
Using Json Object: await _hubContext.Clients.Group(groupName).SendAsync("NotificationResponse", jsonObject);
Using Class Object: await _hubContext.Clients.Group(groupName).SendAsync("NotificationResponse", notificationObject);
I've tried sending object directly from the hub, I was able to send a normal class object but not a json object. I did the testing on my project and also sample from this tutorial: https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-3.1&tabs=visual-studio
I posted this question on github and got the answer from BrennanConroy. Thanks alot !
His answer was:
2.1 was using Newtonsoft internally for Json, 3.1 uses System.Text.Json. If you're using features that don't work with System.Text.Json you can switch back to Newtonsoft https://learn.microsoft.com/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#switch-to-newtonsoftjson
After doing this it fixed the issue.
I have a few draft -03 json schema for some js objects.
And i am using z-schema https://github.com/zaggino/z-schema to validate the schema of js objects.
I am setting remote references with the help of its api setRemoteReference and providing the draft-03 schema object from here
http://json-schema.org/draft-03/schema#
var ZSV = new ZSchemaValidator({ breakOnFirstError: false });
ZSV.setRemoteReference('http://json-schema.org/draft-03/schema#', {
// json object downloaded from draft-03 url
});
But i call validate method it throws error
[{"code":"REMOTE_NOT_VALID","params":["http://json-schema.org/draft-03/schema#"],"message":"Remote reference didn't compile successfully: http://json-schema.org/draft-03/schema#","path":"#/uri(http://json-schema.org/draft-03/schema)","inner": ....
Seems like the compilation failed.
But how come the schema object downloaded from authentic source http://json-schema.org/draft-03/schema# can be wrong.?
Or is it that, z-schema not able to compile draft-03 effectively.?
So my question is, how can i validate draft-03 using z-schema?
If the issue is using v3 schemas in a v4 tool, then you could try json-schema-compatibility.
It normalise schemas to v4 - v3 schemas are updated, v4 schemas are unchanged.
(Full disclosure: I wrote the tool)
Im new Swagger user. I created endpoint with long model definition.
But when endpoint is attached to api-docs, this is not working. I checked that that endpoint configuration file is valid JSON file.
How to check where is the problem with with this file?
Im using Swagger 1.2.
Using bin/validate.sh should be able to help validate the files
https://github.com/swagger-api/swagger-codegen#validating-your-swagger-spec
e.g.
./bin/validate.sh http://petstore.swagger.wordnik.com/api/api-docs "specia-key" ./swagger-errors.html
I'm using the fasterxml json framework version 2.2.0 in order to create the schema in json of the API of the app I'm working on.
My API is similar to : https://gist.github.com/nemo83/5555249
Where Customer and Order both have a reference to Address. Now, when I attempt to generate the schema (https://github.com/FasterXML/jackson-module-jsonSchema) the result is:
{"type":"object","properties":{"address":{"type":"object","properties":{"addressLine2":{"type":"string"},"addressLine1":{"type":"string"}}},"customer":{"type":"object","properties":{"address":{"type":"object","properties":{"addressLine2":{"type":"string"},"addressLine1":{"type":"string"}}},"name":{"type":"string"}}}}}
As you can see the Adress is not represented as a type, but both Customer and Order flatten it in their description.
Is there a way to instruct fasterxml schema generation to address this issue and make use of the "$ref" property for properly reference the Address object?
You can upgrade to jackson-module-jsonSchema 4.1 version where they've resolved this issue and also enabled self referencing classes schema generation possible.