Hi all Now i'm using Axon ivy 6.3. In my project, i have created an Restful API following the OpenAPI Specification Now i want to use Swagger to generate YAML file from those API (follow this guideline and this post). Here is my web.xml and this is my Servlet:
But nothing happen after i restart ivy. Has anybody tried it before? Thanks asked 01.09.2017 at 07:02 trungdv
showing 5 of 14
show 9 more comments
|
I found solution here https://discourse.axonivy.io/t/how-to-apply-swagger-to-ivy-project/607 answered 24.09.2018 at 23:09 trungdv |
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 01.09.2017 at 07:02
Seen: 3,955 times
Last updated: 25.06.2019 at 09:47
I think approaches that rely on classpath scanning will never work out of the box with ivyProjects. As the class hierarchy is not accessible as in standard webApplication-contexts.
But I think you could reach your goal if you generate the swagger resources with the maven plugin: https://github.com/kongchen/swagger-maven-plugin
An alternative approach to document REST services, that work out of the box with Axon.ivy, is the WADL descriptor. Every resource can send an XML similiar to WSDL if you fire an 'OPTIONS' request against it. Here is a sample from our ConnectivityDemos:
Maybe you could convert the WADL automatically into a Swagger2 descriptor: https://github.com/LucyBot-Inc/api-spec-converter
hi @Reguel Werme... ♦♦
I've tried with maven plugon but it does not work. still got no clue. May by i'll try with WSDL. Thanks a lot
hi @Reguel Werme... ♦♦
With second way, can i get WADL from webservice by URL (not use postman)? I've tried some example but it can work with ivy rest api. thanks
The trick is to send the correct accept media type. Postman implicitly sends accept(*) so that WADL is accepted as response. You can explicitly do that like this:
Ivy.rest().client("myService").request().accept("application/vnd.sun.wadl+xml").options();
hi @Reguel Werme... ♦♦ Thanks for your support, i can use WADL but somehow the specification from there it's not very in detail like Swagger can do. It just give me the overview of API but lack of data type for complex object, description of field,...Like in your example, i don't see how many field in object person. but swagger i can see it. Or i miss something?
yep that is the current state. there are no details available how a complex payload (like the person) looks like. and I agree that a swagger service descriptor would be much more state of the art. but WADL is what we have now by default without any effort. But I'm pretty certain that it would be possible to configure the swagger maven plugin to do the job.
hi @Reguel Werme... ♦♦ yes i can make it work within ivy now. It's because after ivy compile, all *.java will be put to <project>/classes, instead of <project>/target/classes. So what i have to do is copy it to rightplace and plugin can run. But somehow it's can't resolve dependency of icy modals.
yes the ivy artifacts are not available with plain maven. because they are p2 bundles and there is no public maven repository that contains them. There are various workaround for it. You could for instance add them manually as POM.xml dependencies with scope 'system'. But that only could if you require just a few bundles - and not the whole engine.
If your setup works, even if just partly, I'd really love to see you sharing a complete example project. It would also give us in the core team an idea how we could better support or demonstrate the use of swagger out of the box.
hi @Reguel Werme... ♦♦ yes, i'm gonna share this. i will send you link later. it work on my project now
@trungdv if you don't find the time to create the demo feel free to send my a link to the POM on your SCM so that I can build the demo on my own. but do it privateby mail reguel[DOT]wermelinger[AT]axonivy[DOT]com
hi @Reguel Werme... ♦♦ i've sent you the pom file via email. Now i'm quite busy and the sharing still on queue :(. Sorry for that
Is there also a way to retrieve the WADL for all resources at once, eg http://localhost:9998/application.wadl?detail=true (like described in https://jersey.github.io/documentation/latest/wadl.html)?