menu
Channels
Team
Posts
Chat
Members
Info
Show previous messages

September 4, 2020 at 10:05pm
The former should be possible. Are you using elide standalone or spring boot?
  • reply
  • like

September 8, 2020 at 3:05pm
Yes, I want to add a non-elide controller to the swagger document.
  • reply
  • like
You can override this bean to get access to the Swagger document:
  • reply
  • like
@ConditionalOnMissingBean
public Swagger buildSwagger(EntityDictionary dictionary, ElideConfigProperties settings) {
Info info = new Info()
.title(settings.getSwagger().getName())
.version(settings.getSwagger().getVersion());
SwaggerBuilder builder = new SwaggerBuilder(dictionary, info).withLegacyFilterDialect(false);
Swagger swagger = builder.build().basePath(settings.getJsonApi().getPath());
return swagger;
}
  • reply
  • like
You can then add your data types and controller directly to the Swagger object.
  • reply
  • like

September 10, 2020 at 3:36pm
The examples I'm finding online is to do something like this
@Configuration
public class Swagger2Config {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.demo.resource"))
.paths(regex("/v1.*"))
.build();
}
}
However, only using the swagger object, I've tried a few different ways of adding the class and I'm not getting any traction:
@RestController
@RequestMapping("/api/v1")
@Api(tags = "Layers")
public class LayerController {
...
@GetMapping("/layers/hospitals/{x}/{y}/{radius}")
public String findNearbyHospitals(@PathVariable double x, @PathVariable double y, @PathVariable double radius) {
return this.toGeoJson(repository.findNearby(x, y, radius)).toString();
}
...
}
and working with swagger I've tried adding a definition
Model lcModel = new ModelImpl()
.name("LayerController")
.type("LayerController");
lcModel.setReference("...");
and working with the model directly - which I'm not finding a lot of examples on
Path value = new Path();
Operation op = new Operation();
swagger.getPaths().put("LayerController", value ); // ???
swagger.path("LayerControl", value); // ???
do you have an example or some direction you can provide to help me with this?
  • reply
  • like

September 10, 2020 at 9:55pm
Elide uses swagger core directly (specifically 1.6.2) which is the latest stable branch.
  • reply
  • like
Swagger core is a lower level API - so Spring won't help here.
  • reply
  • like
The last example above from your different trials is what I was recommending (using Swagger object directly from swagger models). It is possible there is a way to get access to the same object from Spring - but I'm not sure how to do it.
Edited
  • reply
  • like
The Swagger object is pretty much identical to what gets serialized over the wire as the Open API document.
  • reply
  • like
So if you see something in the swagger specification - you can and will find it in the Swagger object.
  • reply
  • like
For example, this is the code that converts the Swagger object to JSON text:
  • reply
  • like
* @param swagger Swagger-Core swagger POJO
* @return Pretty printed 'Swagger' document in JSON.
*/
public static String getDocument(Swagger swagger) {
return Json.pretty(swagger);
}
  • reply
  • like
Json.pretty is provided by swagger directly - and it just uses Jackson to directly serialize it.
  • reply
  • like
This following might also be helpful
Edited
  • reply
  • like
You will notice open API has a few different versions. They are working on 3.0.X. but
Edited
  • reply
  • like
swagger-core uses an older version of the Open API specification:
  • reply
  • like
The above link has the document for the swagger object:
  • reply
  • like
Swagger Object This is the root document object for the API specification. It combines what previously was the Resource Listing and API Declaration (version 1.2 and earlier) together into one document.
  • reply
  • like
Hope that link helps.
  • reply
  • like

September 22, 2020 at 8:32pm
Is there polymorphic support for relationships? There are a few ways to go about this with hibernate but when trying to implement them, I've been getting various errors. The specifications I received require an "action" relationship, allowing one of several Resource Types to be used in the relationship. How can I best support this specification?
  • reply
  • like
Simply, I want to support something like this
{
"data": [
{
"id": "1",
"type": "some_type",
"attributes": {
"attr1": "string"
},
"relationships": {
"action_detail": {
"data": {
"id": "5",
"type": "exercise"
}
}
}
},
{
"id": "2",
"type": "some_type",
"attributes": {
"attr1": "string"
},
"relationships": {
"action_detail": {
"data": {
"id": "66",
"type": "clone_protocol_order"
}
}
}
},
{
"id": "3",
"type": "some_type",
"attributes": {
"attr1": "string"
},
"relationships": {
"action_detail": {
"data": null
}
}
}
]
}
Edited
  • reply
  • like