Thursday, March 23, 2017

Re: GWT + Open API

No, I have not tried generating API interfaces for a CXF client. I don't remember even seeing that option when we first created the api (more than a year ago). I might try that out.

To create our GWT "Models" module, we simply add a gwt module file with these 3 lines:

<module rename-to='Models'>
   <source path="model" />

</module>


to the generated Java source code, package it into a jar file, and we can import and use that module on any GWT app (and also on the server side along with the rest of the generated files, so we can call the same api programmatically).

Our API is externally available (to customers that buy our enterprise product) so that customers can request/manipulate the data with their own RESTful clients if they choose to.


On Thursday, March 23, 2017 at 5:16:58 AM UTC-6, Irek Szczesniak wrote:
Thank you, Rogelio, for your input.

I like the idea of generating the data model from the OpenAPI
specification, because I will not have to write some boring
error-prone code.  I also like the optimization of the GWT compiler.

The swagger-codegen can output Jaxrs Cxf Client, which has the API
interface defined with JAX-RS annotations.  So it seems that even the
interfaces could be auto-generated.  You only have to modify them so
that they extend RestService, required by RestyGWT.

Have you tried auto-generating the API interfaces with Jaxrs Cxf Client?

In your previous message you wrote that you auto-generate a GWT
module.  What do you specifically mean by a module here?  Do you use
some publicly-available tools, or do you have something home-grown?

On 22.03.2017 23:51, Rogelio Flores wrote:
> Yes, those are the Models I was referring to.
>
> I can't compare my approach to JsInterop +
> RequestBuilder/XMLHttpRequest because I haven't tried it, but having
> used RequestBuilder (and direct XMLHttpRequest) before, I can't see
> how you will write less code using that approach. A benefit of doing
> things in Java is that GWT will optimize the resulting javascript
> (Java classes/methods from the generated api that don't get used
> aren't included).
>
>
> On Tuesday, March 21, 2017 at 10:39:09 PM UTC-6, Irek Szczesniak wrote:
>
>     Thanks, Rogelio!
>
>     When you auto-generate Java source code, do you use
>     swagger-codegen to
>     generate Java client code, so that you get Java classes implementing
>     the types from the OpenAPI #/definitions?
>
>     On 21.03.2017 20:50, Rogelio Flores wrote:
>     > We do auto-generate Java source code out of the swagger api
>     (including
>     > a GWT module). That allows us to use the Models on both client and
>     > server side. So we don't have to write much code. Basically all
>     we do
>     > is specify some options for RestyGWT and specify the endpoints.
>     >
>     > On Monday, March 20, 2017 at 11:32:41 PM UTC-6, Irek Szczesniak
>     wrote:
>     >
>     >     Thank you, Rogelio, for your info.
>     >
>     >     But I guess no code is generated automatically, you have to
>     >     develop it
>     >     yourself.  Is this right?
>     >
>     >     I'm not fully for code generation (such code is usually
>     messy and
>     >     hard
>     >     to read), but generating some bits, like a model of the data
>     >     structures could be useful.
>     >
>     >     On 20.03.2017 18:24, Rogelio Flores wrote:
>     >     > We use RestyGWT to consume a swagger REST API and are very
>     pleased
>     >     > with it:
>     >     >
>     >     > https://resty-gwt.github.io/index.html
>     <https://resty-gwt.github.io/index.html>
>     >     <https://resty-gwt.github.io/index.html
>     <https://resty-gwt.github.io/index.html>>
>     >     >
>     >     >
>     >     >
>     >     > On Monday, March 20, 2017 at 7:06:08 AM UTC-6, Irek
>     Szczesniak
>     >     wrote:
>     >     >
>     >     >     Hi,
>     >     >
>     >     >     I need to develop a web client with GWT, which
>     consumes a web
>     >     >     service defined with Open API (formerly Swagger).
>     >     >
>     >     >     I wonder whether someone could offer some advice on
>     how to
>     >     do it
>     >     >     best with GWT.
>     >     >
>     >     >
>     >     >     Thanks,
>     >     >     Irek
>     >     >
>     >     > --
>     >     > You received this message because you are subscribed to a
>     topic
>     >     in the
>     >     > Google Groups "GWT Users" group.
>     >     > To unsubscribe from this topic, visit
>     >     >
>     >
>     https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe
>     <https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe>
>
>     >
>     <https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe
>     <https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe>>.
>
>     >
>     >     > To unsubscribe from this group and all its topics, send an
>     email to
>     >     > google-web-toolkit+unsubscribe@googlegroups.com
>     <javascript:> <javascript:>
>     >     > <mailto:google-web-toolkit+unsubscribe@googlegroups.com
>     <javascript:>
>     >     <javascript:>>.
>     >     > To post to this group, send email to
>     >     > google-we...@googlegroups.com <javascript:>
>     >     > <mailto:google-we...@googlegroups.com <javascript:>>.
>     >     > Visit this group at
>     >     https://groups.google.com/group/google-web-toolkit
>     <https://groups.google.com/group/google-web-toolkit>
>     >     <https://groups.google.com/group/google-web-toolkit
>     <https://groups.google.com/group/google-web-toolkit>>.
>     >     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>
>     >     <https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>>.
>     >
>     > --
>     > You received this message because you are subscribed to a topic
>     in the
>     > Google Groups "GWT Users" group.
>     > To unsubscribe from this topic, visit
>     >
>     https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe
>     <https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe>.
>
>     > To unsubscribe from this group and all its topics, send an email to
>     > google-web-toolkit+unsubscribe@googlegroups.com <javascript:>
>     > <mailto:google-web-toolkit+unsubscribe@googlegroups.com
>     <javascript:>>.
>     > To post to this group, send email to
>     > google-we...@googlegroups.com <javascript:>
>     > <mailto:google-we...@googlegroups.com <javascript:>>.
>     > Visit this group at
>     https://groups.google.com/group/google-web-toolkit
>     <https://groups.google.com/group/google-web-toolkit>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "GWT Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-web-toolkit/hyILXPwx9Pc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> google-web-toolkit+unsubscribe@googlegroups.com
> <mailto:google-web-toolkit+unsubscribe@googlegroups.com>.
> To post to this group, send email to
> google-we...@googlegroups.com
> <mailto:google-we...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment