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 alt text

and this is my Servlet:

public class ApiScanner extends HttpServlet {
    private static final long serialVersionUID = -4192689550210212169L;

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion("1.0.0");
        beanConfig.setSchemes(new String[]{"http"});
        beanConfig.setHost("localhost:8081");
        beanConfig.setBasePath("/ivy/api/designer");
        beanConfig.setResourcePackage("ch.axonivy.fintech.mybank.website.dossier.api");
        beanConfig.setScan(true);
    }
}

But nothing happen after i restart ivy. Has anybody tried it before?

Thanks

asked 01.09.2017 at 07:02

trungdv's gravatar image

trungdv
(suspended)
accept rate: 52%

edited 05.09.2017 at 05:48

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

(04.09.2017 at 03:49) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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:

alt text

Maybe you could convert the WADL automatically into a Swagger2 descriptor: https://github.com/LucyBot-Inc/api-spec-converter

(04.09.2017 at 03:50) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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

(04.09.2017 at 23:41) trungdv trungdv's gravatar image

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

(05.09.2017 at 04:16) trungdv trungdv's gravatar image

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();

(05.09.2017 at 04:19) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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?

(05.09.2017 at 05:23) trungdv trungdv's gravatar image

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.

(05.09.2017 at 09:33) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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.

(06.09.2017 at 03:41) trungdv trungdv's gravatar image

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.

(07.09.2017 at 03:09) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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.

(07.09.2017 at 03:10) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

hi @Reguel Werme... ♦♦ yes, i'm gonna share this. i will send you link later. it work on my project now

(08.09.2017 at 07:25) trungdv trungdv's gravatar image

@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

(28.09.2017 at 03:45) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

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

(03.10.2017 at 03:37) trungdv trungdv's gravatar image

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)?

(25.06.2019 at 09:47) peters peters's gravatar image
showing 5 of 14 show 9 more comments

link

answered 24.09.2018 at 23:09

trungdv's gravatar image

trungdv
(suspended)
accept rate: 52%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×33
×2
×1

Asked: 01.09.2017 at 07:02

Seen: 3,955 times

Last updated: 25.06.2019 at 09:47