You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Brian K <ha...@gmail.com> on 2018/08/22 21:15:01 UTC

swagger-codegen

Hello,

I see by using the Swagger-UI that the REST view is usable by inspecting
the JSON.  For instance, I can get an object via the GET url, and then
execute an action on it by looking at the "$$instanceId" member to fill in
the action string argument that is needed for its actions: "objectID".

But, swagger-codegen seems to ignore this attribute.  Maybe it's because it
starts with $$ and is not a part of the generated swagger specification.
Using a generated client stub (I tried both "java" and "csharp"
generators), I don't see a way of finding out the objectID string needed to
execute the object's actions.

Has anyone been able to execute actions from a REST client generated by
swagger codegen?  For instance, in SimpleApp archetype, can you execute the
UpdateName action of SimpleObject?  Is there a basic piece I'm missing?

Thank you,
Brian

Re: swagger-codegen

Posted by Andi Huber <ah...@apache.org>.
Hello Brian,
thanks for reporting this. We do have some property names $$... in our REST responses which are not part of the schema as you pointed out.

Currently I don't know of a quick workaround. We'll have to work on a solution, which most likely will not be released before the next milestone 2.0.0-M2. Sorry for that!

As I see it, there is an intuitive way to resolve this:

We do have the content negotiation option 'suppress=true' in the response-content-type "application/json;profile=urn:org.apache.isis/v1;suppress=true". We could use this option to suppress all $$... properties, or - if this breaks compatibility -  add a new option e.g. 'suppressAllHidden' which has the desired effect of suppressing all hidden properties int the REST response.

Cheers Andi


On 2018/08/23 20:57:41, Brian K <ha...@gmail.com> wrote: 
> Hi Johan,
> 
> Thanks for the reply.  In using the REST API from a csharp application, I
> want to be able to generate a client stub and code to that.  This is what
> Swagger Codegen is made for.  For the Apache Isis REST implementation, I
> notice the following:
>    1.  All the domain object actions are represented by REST operations
> that take the object's instanceId as the first argument.  This is a string
> that for an integer primary key is something like "i_1".  I see this in the
> REST response as either the property "$$instanceId" or the JSON property
> "instanceId" above the "members" property.
>    2.  This instanceId is not in the Swagger specification generated by
> Isis.  When I load the specification (from the prototyping menu) into
> https://editor.swagger.io/, the response example it creates for the action
> does not include the $$instanceId property that is there when I call that
> endpoint on the Isis application.  This is true for each schema I download
> (public, private, private with prototyping).
> Therefore, the client generated by codegen is not useable without falling
> back to looking directly at the JSON of the REST operation  response.
> 
> It may be a good idea to include the instanceId in the generated
> specification so that these actions can be called from generated clients.
> I could add a read-only property to return the instanceId, but I am hoping
> there is a better way.
> 
> Thanks,
> Brian
> 
> 
> 
> On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>
> wrote:
> 
> > Hi Brian,
> > The restful objects viewer implemented in Apache Isis and exposed by
> > swagger-ui
> > implements the restful objects spec 1)
> > The basic idea is that you can 'discover' the domain.In the case of simple
> > app:
> > you can start out with
> > curl -X GET --header 'Accept: application/json' --header 'Authorization:
> > Basic
> > c3ZlbjpwYXNz'
> >
> > '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> > That will give you among others the oid's.
> > Then update name can be done by
> > curl -X PUT --header 'Content-Type: application/json' --header 'Accept:
> > application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \
> > "name" :
> > { \ "value" : "some new name" \ } \ }'
> >
> > '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
> >
> > Grtz Johan
> >
> > 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
> >
> >
> >
> >
> >
> > On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com  wrote:
> > Hello,
> >
> >
> >
> >
> > I see by using the Swagger-UI that the REST view is usable by inspecting
> >
> > the JSON. For instance, I can get an object via the GET url, and then
> >
> > execute an action on it by looking at the "$$instanceId" member to fill in
> >
> > the action string argument that is needed for its actions: "objectID".
> >
> >
> >
> >
> > But, swagger-codegen seems to ignore this attribute. Maybe it's because it
> >
> > starts with $$ and is not a part of the generated swagger specification.
> >
> > Using a generated client stub (I tried both "java" and "csharp"
> >
> > generators), I don't see a way of finding out the objectID string needed to
> >
> > execute the object's actions.
> >
> >
> >
> >
> > Has anyone been able to execute actions from a REST client generated by
> >
> > swagger codegen? For instance, in SimpleApp archetype, can you execute the
> >
> > UpdateName action of SimpleObject? Is there a basic piece I'm missing?
> >
> >
> >
> >
> > Thank you,
> >
> > Brian
> 

Re: swagger-codegen

Posted by Brian K <ha...@gmail.com>.
Hi Dan,

I think this will help.  I was looking at IsisJdoSupport and it was only
giving me the primary key value.

Thanks!
Brian

On Fri, Aug 31, 2018, 2:55 PM Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Hi Brian,
>
> As a workaround, you could try surfacing the underlying Id as a regular
> (derived) property.  Something like this will work for all persistent
> entities:
>
>     @Property(editing = Editing.DISABLED)
>     public String getId() {
>         Object objectId = JDOHelper.getObjectId(this);
>         if (objectId == null) {
>             return "";
>         }
>         String objectIdStr = objectId.toString();
>         final String id = objectIdStr.split("\\[OID\\]")[0];
>         return id;
>     }
>
> Admittedly, you would need to dig a little deeper if its a view model being
> represented.
>
> Does that help?
>
> Dan
>
>
>
> On Fri, 31 Aug 2018 at 23:36 Brian K <ha...@gmail.com> wrote:
>
> > Hi Andi,
> >
> > Thanks for opening the ticket.  I don't know that the hidden attributes
> > would cause an error in the generated client; I haven't gotten as far as
> > testing it because I couldn't get code that sufficed.  The generated
> client
> > just doesn't have access to the object id that is required for invoking
> an
> > object's actions.
> >
> > As for a work-around - I don't see where I'd get the object id from, so I
> > can't readily put it in a read-only property.  If you can point me to
> where
> > I'd get, for example, "i_1" from an object with a single integer primary
> > key, then I could make such a property.  Otherwise, it'll be a bit more
> of
> > a kludge to code the property to return "i_" + this.id or have a
> > DomainService action that takes the primary key among its arguments.
> >
> > Thanks again!
> > Brian
> >
> > On Tue, Aug 28, 2018 at 9:45 PM Andi Huber <ah...@apache.org> wrote:
> >
> > > We are tracking this issue [1] now.
> > >
> > > [1] https://issues.apache.org/jira/browse/ISIS-1975
> > >
> > > On 2018/08/24 08:38:12, Johan Doornenbal <johandoornenbal@filternet.nl
> >
> > > wrote:
> > > > Hi Brian,
> > > > Ah, sorry for responding to quickly. I clearly missed your
> point.Indeed
> > > all the
> > > > $$xxx properties are not in the example response like you
> > > indicate.However, at
> > > > the moment I am not aware of the reason why it is implemented this
> > > way...(My
> > > > guess would be the different representation types)
> > > > Maybe somebody else has thoughts on this?
> > > > grtz Johan
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Thu, Aug 23, 2018 10:57 PM, Brian K harvestmoon299@gmail.com
> > wrote:
> > > > Hi Johan,
> > > >
> > > >
> > > >
> > > >
> > > > Thanks for the reply. In using the REST API from a csharp
> application,
> > I
> > > >
> > > > want to be able to generate a client stub and code to that. This is
> > what
> > > >
> > > > Swagger Codegen is made for. For the Apache Isis REST
> implementation, I
> > > >
> > > > notice the following:
> > > >
> > > >   1. All the domain object actions are represented by REST operations
> > > >
> > > > that take the object's instanceId as the first argument. This is a
> > string
> > > >
> > > > that for an integer primary key is something like "i_1". I see this
> in
> > > the
> > > >
> > > > REST response as either the property "$$instanceId" or the JSON
> > property
> > > >
> > > > "instanceId" above the "members" property.
> > > >
> > > >   2. This instanceId is not in the Swagger specification generated by
> > > >
> > > > Isis. When I load the specification (from the prototyping menu) into
> > > >
> > > > https://editor.swagger.io/, the response example it creates for the
> > > action
> > > >
> > > > does not include the $$instanceId property that is there when I call
> > that
> > > >
> > > > endpoint on the Isis application. This is true for each schema I
> > download
> > > >
> > > > (public, private, private with prototyping).
> > > >
> > > > Therefore, the client generated by codegen is not useable without
> > falling
> > > >
> > > > back to looking directly at the JSON of the REST operation response.
> > > >
> > > >
> > > >
> > > >
> > > > It may be a good idea to include the instanceId in the generated
> > > >
> > > > specification so that these actions can be called from generated
> > clients.
> > > >
> > > > I could add a read-only property to return the instanceId, but I am
> > > hoping
> > > >
> > > > there is a better way.
> > > >
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > Brian
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <
> johan@filternet.nl>
> > > >
> > > > wrote:
> > > >
> > > >
> > > >
> > > >
> > > > > Hi Brian,
> > > >
> > > > > The restful objects viewer implemented in Apache Isis and exposed
> by
> > > >
> > > > > swagger-ui
> > > >
> > > > > implements the restful objects spec 1)
> > > >
> > > > > The basic idea is that you can 'discover' the domain.In the case of
> > > simple
> > > >
> > > > > app:
> > > >
> > > > > you can start out with
> > > >
> > > > > curl -X GET --header 'Accept: application/json' --header
> > > 'Authorization:
> > > >
> > > > > Basic
> > > >
> > > > > c3ZlbjpwYXNz'
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > >
> >
> '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> > > >
> > > > > That will give you among others the oid's.
> > > >
> > > > > Then update name can be done by
> > > >
> > > > > curl -X PUT --header 'Content-Type: application/json' --header
> > 'Accept:
> > > >
> > > > > application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d
> '{
> > \
> > > >
> > > > > "name" :
> > > >
> > > > > { \ "value" : "some new name" \ } \ }'
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > >
> >
> '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
> > > >
> > > > >
> > > >
> > > > > Grtz Johan
> > > >
> > > > >
> > > >
> > > > > 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > > On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com
> > wrote:
> > > >
> > > > > Hello,
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > > I see by using the Swagger-UI that the REST view is usable by
> > > inspecting
> > > >
> > > > >
> > > >
> > > > > the JSON. For instance, I can get an object via the GET url, and
> then
> > > >
> > > > >
> > > >
> > > > > execute an action on it by looking at the "$$instanceId" member to
> > > fill in
> > > >
> > > > >
> > > >
> > > > > the action string argument that is needed for its actions:
> > "objectID".
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > > But, swagger-codegen seems to ignore this attribute. Maybe it's
> > > because it
> > > >
> > > > >
> > > >
> > > > > starts with $$ and is not a part of the generated swagger
> > > specification.
> > > >
> > > > >
> > > >
> > > > > Using a generated client stub (I tried both "java" and "csharp"
> > > >
> > > > >
> > > >
> > > > > generators), I don't see a way of finding out the objectID string
> > > needed to
> > > >
> > > > >
> > > >
> > > > > execute the object's actions.
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > > Has anyone been able to execute actions from a REST client
> generated
> > by
> > > >
> > > > >
> > > >
> > > > > swagger codegen? For instance, in SimpleApp archetype, can you
> > execute
> > > the
> > > >
> > > > >
> > > >
> > > > > UpdateName action of SimpleObject? Is there a basic piece I'm
> > missing?
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > >
> > > >
> > > > > Thank you,
> > > >
> > > > >
> > > >
> > > > > Brian
> > >
> >
> --
> DISCLAIMER: This e-mail is from Haywood Associates Ltd (Registered Number
> 3525455) and it and its attachments may be confidential and are intended
> solely for the use of the individual to whom it is addressed.  Any
> unauthorised use or dissemination of this communication is strictly
> prohibited. Any information provided to Haywood Associates Ltd shall be
> retained and used in accordance with our Privacy Statement at
> http://www.haywood-associates.co.uk/privacy.  If you have received this
> communication in error, please immediately notify the sender by return
> e-mail message and delete all copies of the original communication.
>

Re: swagger-codegen

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Brian,

As a workaround, you could try surfacing the underlying Id as a regular
(derived) property.  Something like this will work for all persistent
entities:

    @Property(editing = Editing.DISABLED)
    public String getId() {
        Object objectId = JDOHelper.getObjectId(this);
        if (objectId == null) {
            return "";
        }
        String objectIdStr = objectId.toString();
        final String id = objectIdStr.split("\\[OID\\]")[0];
        return id;
    }

Admittedly, you would need to dig a little deeper if its a view model being
represented.

Does that help?

Dan



On Fri, 31 Aug 2018 at 23:36 Brian K <ha...@gmail.com> wrote:

> Hi Andi,
>
> Thanks for opening the ticket.  I don't know that the hidden attributes
> would cause an error in the generated client; I haven't gotten as far as
> testing it because I couldn't get code that sufficed.  The generated client
> just doesn't have access to the object id that is required for invoking an
> object's actions.
>
> As for a work-around - I don't see where I'd get the object id from, so I
> can't readily put it in a read-only property.  If you can point me to where
> I'd get, for example, "i_1" from an object with a single integer primary
> key, then I could make such a property.  Otherwise, it'll be a bit more of
> a kludge to code the property to return "i_" + this.id or have a
> DomainService action that takes the primary key among its arguments.
>
> Thanks again!
> Brian
>
> On Tue, Aug 28, 2018 at 9:45 PM Andi Huber <ah...@apache.org> wrote:
>
> > We are tracking this issue [1] now.
> >
> > [1] https://issues.apache.org/jira/browse/ISIS-1975
> >
> > On 2018/08/24 08:38:12, Johan Doornenbal <jo...@filternet.nl>
> > wrote:
> > > Hi Brian,
> > > Ah, sorry for responding to quickly. I clearly missed your point.Indeed
> > all the
> > > $$xxx properties are not in the example response like you
> > indicate.However, at
> > > the moment I am not aware of the reason why it is implemented this
> > way...(My
> > > guess would be the different representation types)
> > > Maybe somebody else has thoughts on this?
> > > grtz Johan
> > >
> > >
> > >
> > >
> > >
> > > On Thu, Aug 23, 2018 10:57 PM, Brian K harvestmoon299@gmail.com
> wrote:
> > > Hi Johan,
> > >
> > >
> > >
> > >
> > > Thanks for the reply. In using the REST API from a csharp application,
> I
> > >
> > > want to be able to generate a client stub and code to that. This is
> what
> > >
> > > Swagger Codegen is made for. For the Apache Isis REST implementation, I
> > >
> > > notice the following:
> > >
> > >   1. All the domain object actions are represented by REST operations
> > >
> > > that take the object's instanceId as the first argument. This is a
> string
> > >
> > > that for an integer primary key is something like "i_1". I see this in
> > the
> > >
> > > REST response as either the property "$$instanceId" or the JSON
> property
> > >
> > > "instanceId" above the "members" property.
> > >
> > >   2. This instanceId is not in the Swagger specification generated by
> > >
> > > Isis. When I load the specification (from the prototyping menu) into
> > >
> > > https://editor.swagger.io/, the response example it creates for the
> > action
> > >
> > > does not include the $$instanceId property that is there when I call
> that
> > >
> > > endpoint on the Isis application. This is true for each schema I
> download
> > >
> > > (public, private, private with prototyping).
> > >
> > > Therefore, the client generated by codegen is not useable without
> falling
> > >
> > > back to looking directly at the JSON of the REST operation response.
> > >
> > >
> > >
> > >
> > > It may be a good idea to include the instanceId in the generated
> > >
> > > specification so that these actions can be called from generated
> clients.
> > >
> > > I could add a read-only property to return the instanceId, but I am
> > hoping
> > >
> > > there is a better way.
> > >
> > >
> > >
> > >
> > > Thanks,
> > >
> > > Brian
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>
> > >
> > > wrote:
> > >
> > >
> > >
> > >
> > > > Hi Brian,
> > >
> > > > The restful objects viewer implemented in Apache Isis and exposed by
> > >
> > > > swagger-ui
> > >
> > > > implements the restful objects spec 1)
> > >
> > > > The basic idea is that you can 'discover' the domain.In the case of
> > simple
> > >
> > > > app:
> > >
> > > > you can start out with
> > >
> > > > curl -X GET --header 'Accept: application/json' --header
> > 'Authorization:
> > >
> > > > Basic
> > >
> > > > c3ZlbjpwYXNz'
> > >
> > > >
> > >
> > > >
> > >
> >
> '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> > >
> > > > That will give you among others the oid's.
> > >
> > > > Then update name can be done by
> > >
> > > > curl -X PUT --header 'Content-Type: application/json' --header
> 'Accept:
> > >
> > > > application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{
> \
> > >
> > > > "name" :
> > >
> > > > { \ "value" : "some new name" \ } \ }'
> > >
> > > >
> > >
> > > >
> > >
> >
> '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
> > >
> > > >
> > >
> > > > Grtz Johan
> > >
> > > >
> > >
> > > > 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com
> wrote:
> > >
> > > > Hello,
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > I see by using the Swagger-UI that the REST view is usable by
> > inspecting
> > >
> > > >
> > >
> > > > the JSON. For instance, I can get an object via the GET url, and then
> > >
> > > >
> > >
> > > > execute an action on it by looking at the "$$instanceId" member to
> > fill in
> > >
> > > >
> > >
> > > > the action string argument that is needed for its actions:
> "objectID".
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > But, swagger-codegen seems to ignore this attribute. Maybe it's
> > because it
> > >
> > > >
> > >
> > > > starts with $$ and is not a part of the generated swagger
> > specification.
> > >
> > > >
> > >
> > > > Using a generated client stub (I tried both "java" and "csharp"
> > >
> > > >
> > >
> > > > generators), I don't see a way of finding out the objectID string
> > needed to
> > >
> > > >
> > >
> > > > execute the object's actions.
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > Has anyone been able to execute actions from a REST client generated
> by
> > >
> > > >
> > >
> > > > swagger codegen? For instance, in SimpleApp archetype, can you
> execute
> > the
> > >
> > > >
> > >
> > > > UpdateName action of SimpleObject? Is there a basic piece I'm
> missing?
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > Thank you,
> > >
> > > >
> > >
> > > > Brian
> >
>
-- 
DISCLAIMER: This e-mail is from Haywood Associates Ltd (Registered Number
3525455) and it and its attachments may be confidential and are intended
solely for the use of the individual to whom it is addressed.  Any
unauthorised use or dissemination of this communication is strictly
prohibited. Any information provided to Haywood Associates Ltd shall be
retained and used in accordance with our Privacy Statement at
http://www.haywood-associates.co.uk/privacy.  If you have received this
communication in error, please immediately notify the sender by return
e-mail message and delete all copies of the original communication.

Re: swagger-codegen

Posted by Brian K <ha...@gmail.com>.
Hi Andi,

Thanks for opening the ticket.  I don't know that the hidden attributes
would cause an error in the generated client; I haven't gotten as far as
testing it because I couldn't get code that sufficed.  The generated client
just doesn't have access to the object id that is required for invoking an
object's actions.

As for a work-around - I don't see where I'd get the object id from, so I
can't readily put it in a read-only property.  If you can point me to where
I'd get, for example, "i_1" from an object with a single integer primary
key, then I could make such a property.  Otherwise, it'll be a bit more of
a kludge to code the property to return "i_" + this.id or have a
DomainService action that takes the primary key among its arguments.

Thanks again!
Brian

On Tue, Aug 28, 2018 at 9:45 PM Andi Huber <ah...@apache.org> wrote:

> We are tracking this issue [1] now.
>
> [1] https://issues.apache.org/jira/browse/ISIS-1975
>
> On 2018/08/24 08:38:12, Johan Doornenbal <jo...@filternet.nl>
> wrote:
> > Hi Brian,
> > Ah, sorry for responding to quickly. I clearly missed your point.Indeed
> all the
> > $$xxx properties are not in the example response like you
> indicate.However, at
> > the moment I am not aware of the reason why it is implemented this
> way...(My
> > guess would be the different representation types)
> > Maybe somebody else has thoughts on this?
> > grtz Johan
> >
> >
> >
> >
> >
> > On Thu, Aug 23, 2018 10:57 PM, Brian K harvestmoon299@gmail.com  wrote:
> > Hi Johan,
> >
> >
> >
> >
> > Thanks for the reply. In using the REST API from a csharp application, I
> >
> > want to be able to generate a client stub and code to that. This is what
> >
> > Swagger Codegen is made for. For the Apache Isis REST implementation, I
> >
> > notice the following:
> >
> >   1. All the domain object actions are represented by REST operations
> >
> > that take the object's instanceId as the first argument. This is a string
> >
> > that for an integer primary key is something like "i_1". I see this in
> the
> >
> > REST response as either the property "$$instanceId" or the JSON property
> >
> > "instanceId" above the "members" property.
> >
> >   2. This instanceId is not in the Swagger specification generated by
> >
> > Isis. When I load the specification (from the prototyping menu) into
> >
> > https://editor.swagger.io/, the response example it creates for the
> action
> >
> > does not include the $$instanceId property that is there when I call that
> >
> > endpoint on the Isis application. This is true for each schema I download
> >
> > (public, private, private with prototyping).
> >
> > Therefore, the client generated by codegen is not useable without falling
> >
> > back to looking directly at the JSON of the REST operation response.
> >
> >
> >
> >
> > It may be a good idea to include the instanceId in the generated
> >
> > specification so that these actions can be called from generated clients.
> >
> > I could add a read-only property to return the instanceId, but I am
> hoping
> >
> > there is a better way.
> >
> >
> >
> >
> > Thanks,
> >
> > Brian
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>
> >
> > wrote:
> >
> >
> >
> >
> > > Hi Brian,
> >
> > > The restful objects viewer implemented in Apache Isis and exposed by
> >
> > > swagger-ui
> >
> > > implements the restful objects spec 1)
> >
> > > The basic idea is that you can 'discover' the domain.In the case of
> simple
> >
> > > app:
> >
> > > you can start out with
> >
> > > curl -X GET --header 'Accept: application/json' --header
> 'Authorization:
> >
> > > Basic
> >
> > > c3ZlbjpwYXNz'
> >
> > >
> >
> > >
> >
> '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> >
> > > That will give you among others the oid's.
> >
> > > Then update name can be done by
> >
> > > curl -X PUT --header 'Content-Type: application/json' --header 'Accept:
> >
> > > application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \
> >
> > > "name" :
> >
> > > { \ "value" : "some new name" \ } \ }'
> >
> > >
> >
> > >
> >
> '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
> >
> > >
> >
> > > Grtz Johan
> >
> > >
> >
> > > 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com wrote:
> >
> > > Hello,
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > I see by using the Swagger-UI that the REST view is usable by
> inspecting
> >
> > >
> >
> > > the JSON. For instance, I can get an object via the GET url, and then
> >
> > >
> >
> > > execute an action on it by looking at the "$$instanceId" member to
> fill in
> >
> > >
> >
> > > the action string argument that is needed for its actions: "objectID".
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > But, swagger-codegen seems to ignore this attribute. Maybe it's
> because it
> >
> > >
> >
> > > starts with $$ and is not a part of the generated swagger
> specification.
> >
> > >
> >
> > > Using a generated client stub (I tried both "java" and "csharp"
> >
> > >
> >
> > > generators), I don't see a way of finding out the objectID string
> needed to
> >
> > >
> >
> > > execute the object's actions.
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > Has anyone been able to execute actions from a REST client generated by
> >
> > >
> >
> > > swagger codegen? For instance, in SimpleApp archetype, can you execute
> the
> >
> > >
> >
> > > UpdateName action of SimpleObject? Is there a basic piece I'm missing?
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > Thank you,
> >
> > >
> >
> > > Brian
>

Re: swagger-codegen

Posted by Andi Huber <ah...@apache.org>.
We are tracking this issue [1] now.

[1] https://issues.apache.org/jira/browse/ISIS-1975

On 2018/08/24 08:38:12, Johan Doornenbal <jo...@filternet.nl> wrote: 
> Hi Brian,
> Ah, sorry for responding to quickly. I clearly missed your point.Indeed all the
> $$xxx properties are not in the example response like you indicate.However, at
> the moment I am not aware of the reason why it is implemented this way...(My
> guess would be the different representation types)
> Maybe somebody else has thoughts on this?
> grtz Johan  
> 
> 
> 
> 
> 
> On Thu, Aug 23, 2018 10:57 PM, Brian K harvestmoon299@gmail.com  wrote:
> Hi Johan,
> 
> 
> 
> 
> Thanks for the reply. In using the REST API from a csharp application, I
> 
> want to be able to generate a client stub and code to that. This is what
> 
> Swagger Codegen is made for. For the Apache Isis REST implementation, I
> 
> notice the following:
> 
>   1. All the domain object actions are represented by REST operations
> 
> that take the object's instanceId as the first argument. This is a string
> 
> that for an integer primary key is something like "i_1". I see this in the
> 
> REST response as either the property "$$instanceId" or the JSON property
> 
> "instanceId" above the "members" property.
> 
>   2. This instanceId is not in the Swagger specification generated by
> 
> Isis. When I load the specification (from the prototyping menu) into
> 
> https://editor.swagger.io/, the response example it creates for the action
> 
> does not include the $$instanceId property that is there when I call that
> 
> endpoint on the Isis application. This is true for each schema I download
> 
> (public, private, private with prototyping).
> 
> Therefore, the client generated by codegen is not useable without falling
> 
> back to looking directly at the JSON of the REST operation response.
> 
> 
> 
> 
> It may be a good idea to include the instanceId in the generated
> 
> specification so that these actions can be called from generated clients.
> 
> I could add a read-only property to return the instanceId, but I am hoping
> 
> there is a better way.
> 
> 
> 
> 
> Thanks,
> 
> Brian
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>
> 
> wrote:
> 
> 
> 
> 
> > Hi Brian,
> 
> > The restful objects viewer implemented in Apache Isis and exposed by
> 
> > swagger-ui
> 
> > implements the restful objects spec 1)
> 
> > The basic idea is that you can 'discover' the domain.In the case of simple
> 
> > app:
> 
> > you can start out with
> 
> > curl -X GET --header 'Accept: application/json' --header 'Authorization:
> 
> > Basic
> 
> > c3ZlbjpwYXNz'
> 
> >
> 
> >
> '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> 
> > That will give you among others the oid's.
> 
> > Then update name can be done by
> 
> > curl -X PUT --header 'Content-Type: application/json' --header 'Accept:
> 
> > application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \
> 
> > "name" :
> 
> > { \ "value" : "some new name" \ } \ }'
> 
> >
> 
> >
> '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
> 
> >
> 
> > Grtz Johan
> 
> >
> 
> > 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com wrote:
> 
> > Hello,
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > I see by using the Swagger-UI that the REST view is usable by inspecting
> 
> >
> 
> > the JSON. For instance, I can get an object via the GET url, and then
> 
> >
> 
> > execute an action on it by looking at the "$$instanceId" member to fill in
> 
> >
> 
> > the action string argument that is needed for its actions: "objectID".
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > But, swagger-codegen seems to ignore this attribute. Maybe it's because it
> 
> >
> 
> > starts with $$ and is not a part of the generated swagger specification.
> 
> >
> 
> > Using a generated client stub (I tried both "java" and "csharp"
> 
> >
> 
> > generators), I don't see a way of finding out the objectID string needed to
> 
> >
> 
> > execute the object's actions.
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Has anyone been able to execute actions from a REST client generated by
> 
> >
> 
> > swagger codegen? For instance, in SimpleApp archetype, can you execute the
> 
> >
> 
> > UpdateName action of SimpleObject? Is there a basic piece I'm missing?
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Thank you,
> 
> >
> 
> > Brian

Re: swagger-codegen

Posted by Johan Doornenbal <jo...@filternet.nl>.
Hi Brian,
Ah, sorry for responding to quickly. I clearly missed your point.Indeed all the
$$xxx properties are not in the example response like you indicate.However, at
the moment I am not aware of the reason why it is implemented this way...(My
guess would be the different representation types)
Maybe somebody else has thoughts on this?
grtz Johan  





On Thu, Aug 23, 2018 10:57 PM, Brian K harvestmoon299@gmail.com  wrote:
Hi Johan,




Thanks for the reply. In using the REST API from a csharp application, I

want to be able to generate a client stub and code to that. This is what

Swagger Codegen is made for. For the Apache Isis REST implementation, I

notice the following:

  1. All the domain object actions are represented by REST operations

that take the object's instanceId as the first argument. This is a string

that for an integer primary key is something like "i_1". I see this in the

REST response as either the property "$$instanceId" or the JSON property

"instanceId" above the "members" property.

  2. This instanceId is not in the Swagger specification generated by

Isis. When I load the specification (from the prototyping menu) into

https://editor.swagger.io/, the response example it creates for the action

does not include the $$instanceId property that is there when I call that

endpoint on the Isis application. This is true for each schema I download

(public, private, private with prototyping).

Therefore, the client generated by codegen is not useable without falling

back to looking directly at the JSON of the REST operation response.




It may be a good idea to include the instanceId in the generated

specification so that these actions can be called from generated clients.

I could add a read-only property to return the instanceId, but I am hoping

there is a better way.




Thanks,

Brian










On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>

wrote:




> Hi Brian,

> The restful objects viewer implemented in Apache Isis and exposed by

> swagger-ui

> implements the restful objects spec 1)

> The basic idea is that you can 'discover' the domain.In the case of simple

> app:

> you can start out with

> curl -X GET --header 'Accept: application/json' --header 'Authorization:

> Basic

> c3ZlbjpwYXNz'

>

>
'[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'

> That will give you among others the oid's.

> Then update name can be done by

> curl -X PUT --header 'Content-Type: application/json' --header 'Accept:

> application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \

> "name" :

> { \ "value" : "some new name" \ } \ }'

>

>
'[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'

>

> Grtz Johan

>

> 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro

>

>

>

>

>

> On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com wrote:

> Hello,

>

>

>

>

> I see by using the Swagger-UI that the REST view is usable by inspecting

>

> the JSON. For instance, I can get an object via the GET url, and then

>

> execute an action on it by looking at the "$$instanceId" member to fill in

>

> the action string argument that is needed for its actions: "objectID".

>

>

>

>

> But, swagger-codegen seems to ignore this attribute. Maybe it's because it

>

> starts with $$ and is not a part of the generated swagger specification.

>

> Using a generated client stub (I tried both "java" and "csharp"

>

> generators), I don't see a way of finding out the objectID string needed to

>

> execute the object's actions.

>

>

>

>

> Has anyone been able to execute actions from a REST client generated by

>

> swagger codegen? For instance, in SimpleApp archetype, can you execute the

>

> UpdateName action of SimpleObject? Is there a basic piece I'm missing?

>

>

>

>

> Thank you,

>

> Brian

Re: swagger-codegen

Posted by Brian K <ha...@gmail.com>.
Hi Johan,

Thanks for the reply.  In using the REST API from a csharp application, I
want to be able to generate a client stub and code to that.  This is what
Swagger Codegen is made for.  For the Apache Isis REST implementation, I
notice the following:
   1.  All the domain object actions are represented by REST operations
that take the object's instanceId as the first argument.  This is a string
that for an integer primary key is something like "i_1".  I see this in the
REST response as either the property "$$instanceId" or the JSON property
"instanceId" above the "members" property.
   2.  This instanceId is not in the Swagger specification generated by
Isis.  When I load the specification (from the prototyping menu) into
https://editor.swagger.io/, the response example it creates for the action
does not include the $$instanceId property that is there when I call that
endpoint on the Isis application.  This is true for each schema I download
(public, private, private with prototyping).
Therefore, the client generated by codegen is not useable without falling
back to looking directly at the JSON of the REST operation  response.

It may be a good idea to include the instanceId in the generated
specification so that these actions can be called from generated clients.
I could add a read-only property to return the instanceId, but I am hoping
there is a better way.

Thanks,
Brian



On Wed, Aug 22, 2018 at 10:48 PM Johan Doornenbal <jo...@filternet.nl>
wrote:

> Hi Brian,
> The restful objects viewer implemented in Apache Isis and exposed by
> swagger-ui
> implements the restful objects spec 1)
> The basic idea is that you can 'discover' the domain.In the case of simple
> app:
> you can start out with
> curl -X GET --header 'Accept: application/json' --header 'Authorization:
> Basic
> c3ZlbjpwYXNz'
>
> '[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
> That will give you among others the oid's.
> Then update name can be done by
> curl -X PUT --header 'Content-Type: application/json' --header 'Accept:
> application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \
> "name" :
> { \ "value" : "some new name" \ } \ }'
>
> '[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'
>
> Grtz Johan
>
> 1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro
>
>
>
>
>
> On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com  wrote:
> Hello,
>
>
>
>
> I see by using the Swagger-UI that the REST view is usable by inspecting
>
> the JSON. For instance, I can get an object via the GET url, and then
>
> execute an action on it by looking at the "$$instanceId" member to fill in
>
> the action string argument that is needed for its actions: "objectID".
>
>
>
>
> But, swagger-codegen seems to ignore this attribute. Maybe it's because it
>
> starts with $$ and is not a part of the generated swagger specification.
>
> Using a generated client stub (I tried both "java" and "csharp"
>
> generators), I don't see a way of finding out the objectID string needed to
>
> execute the object's actions.
>
>
>
>
> Has anyone been able to execute actions from a REST client generated by
>
> swagger codegen? For instance, in SimpleApp archetype, can you execute the
>
> UpdateName action of SimpleObject? Is there a basic piece I'm missing?
>
>
>
>
> Thank you,
>
> Brian

Re: swagger-codegen

Posted by Johan Doornenbal <jo...@filternet.nl>.
Hi Brian,
The restful objects viewer implemented in Apache Isis and exposed by swagger-ui
implements the restful objects spec 1)
The basic idea is that you can 'discover' the domain.In the case of simple app:
you can start out with
curl -X GET --header 'Accept: application/json' --header 'Authorization: Basic
c3ZlbjpwYXNz'
'[YOUR_BASE_URL]/restful/services/simple.SimpleObjectMenu/actions/listAll/invoke'
That will give you among others the oid's.
Then update name can be done by
curl -X PUT --header 'Content-Type: application/json' --header 'Accept:
application/json' --header 'Authorization: Basic c3ZlbjpwYXNz' -d '{ \ "name" :
{ \ "value" : "some new name" \ } \ }'
'[YOUR_BASE_URL]/restful/objects/simple.SimpleObject/0/actions/updateName/invoke'

Grtz Johan

1) http://isis.apache.org/guides/ugvro/ugvro.html#__ugvro  





On Wed, Aug 22, 2018 11:15 PM, Brian K harvestmoon299@gmail.com  wrote:
Hello,




I see by using the Swagger-UI that the REST view is usable by inspecting

the JSON. For instance, I can get an object via the GET url, and then

execute an action on it by looking at the "$$instanceId" member to fill in

the action string argument that is needed for its actions: "objectID".




But, swagger-codegen seems to ignore this attribute. Maybe it's because it

starts with $$ and is not a part of the generated swagger specification.

Using a generated client stub (I tried both "java" and "csharp"

generators), I don't see a way of finding out the objectID string needed to

execute the object's actions.




Has anyone been able to execute actions from a REST client generated by

swagger codegen? For instance, in SimpleApp archetype, can you execute the

UpdateName action of SimpleObject? Is there a basic piece I'm missing?




Thank you,

Brian