Routes ignoring schema

79 views
Skip to first unread message

maurosant...@gmail.com

unread,
May 17, 2020, 10:27:18 PM5/17/20
to Fusio
Hi,

Routes created with backend app are ignoring selected schema, instead retrieve default action schema.

Best regards


kevin...@nexushealthcare.com

unread,
May 19, 2020, 12:34:28 AM5/19/20
to Fusio
Can you provide an example?:

maurosant...@gmail.com

unread,
May 21, 2020, 6:23:22 AM5/21/20
to Fusio
Just edit route, change schema response for some custom you made and the response is allways the same.
note: I'm, using sqlite as fusio DB. 

Christoph Kappestein

unread,
May 21, 2020, 9:56:50 AM5/21/20
to Fusio

Hi,

using sqlite should be no problem, but you need to change the request schema to a custom schema, the response schema can still be Passhtru.
Otherwise you need to use the getPayload method as explained in issue https://github.com/apioo/fusio/issues/316

best regards
Christoph

 

maurosant...@gmail.com

unread,
May 21, 2020, 9:18:25 PM5/21/20
to Fusio
HI Christoph,
Thank you for helping.

I might not been explicit with the problem.

In the GET method of the ROUTE I have the following custom response schema for OK 200:

{
    "title": "GanttTasksCollection",
    "type": "object",
    "properties": {
        "data": {
            "type": "array",
            "items": {
                "title": "GanttTasks",
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "start_date": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "text": {
                        "type": "string"
                    },
                    "progress": {
                        "type": "number"
                    },
                    "duration": {
                        "type": "integer"
                    },
                    "parent": {
                        "type": "integer"
                    },
                    "sortorder": {
                        "type": "integer"
                    },
                    "priority": {
                        "type": "integer"
                    },
                    "type": {
                        "type": "string"
                    },
                    "readonly": {
                        "type": "integer"
                    },
                    "editable": {
                        "type": "integer"
                    },
                    "open": {
                        "type": "integer"
                    },
                    "obraid": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}

And I´m retriving this :

{ "totalResults": 3, "itemsPerPage": 16, "startIndex": 0, "entry": [ { "id": "1", "start_date": "2020-05-20 08:00", "text": "Tarefa #1", "progress": "0.0", "duration": "1", "parent": "0", "sortorder": "1", "priority": null, "type": "project", "readonly": null, "editable": null, "open": null, "ObraID": "1" }, { "id": "2", "start_date": "2020-05-20 08:00", "text": "Tarefa #1.1", "progress": "0.3", "duration": "24", "parent": "1", "sortorder": "1", "priority": null, "type": "task", "readonly": null, "editable": null, "open": null, "ObraID": "1" }, { "id": "4", "start_date": "2020-05-22 08:00", "text": "Tarefa #2", "progress": "0.9", "duration": "12", "parent": "0", "sortorder": "2", "priority": null, "type": "task", "readonly": null, "editable": null, "open": null, "ObraID": "1" } ] }

Best regards

Mauro Madeira

Christoph Kappestein

unread,
May 22, 2020, 12:23:46 PM5/22/20
to Fusio

Hi Mauro,

ok, so the response format of your API depends on your action, it looks like you use the SQL-Table action, if you want to have a response format like described in the schema you need to build a custom action which produces this format.

best regards
Christoph


bi...@abinfo.de

unread,
Mar 2, 2021, 3:28:02 AM3/2/21
to Fusio
Hi Christoph,

after creating my first connection+schema+action+route and trying to test schema changes I determined same issue: Using an sql query in the action the schema has no influence to the result.
Do everything with the backend GUI. What meaning has the schema selection for route response if it is not considered and you suggested to adapt the action instead to give the right format?

My idea is to have for example one general action that provides the data from database and different routes with different schemas that show data for the specific use case. Any idea?

Best regards
Andreas

Christoph Kappestein

unread,
Mar 4, 2021, 1:32:42 PM3/4/21
to Fusio
Hi Andreas,

so in general the idea is that the response schema only describes the data which an action produces. This schema is then used i.e. to generate an OpenAPI specification or generate client SDK code. Iam not 100% sure whether I understand your suggestion, but I see no clean way how Fusio could transform an arbitrary JSON response from an action to a response schema format since for this case we would need some sort of mapping logic.

best regards
Christoph

bi...@abinfo.de

unread,
Mar 5, 2021, 12:49:53 AM3/5/21
to Fusio
Hi Christoph,

thanks for clarification. You're right - there must be some "magic" transformation to solve this demand. My idea was to have a general action that response fields from a database and then having different schemas that provide only limited fields for different endpoints. Acturally, at a closer look, that doesn't make sense due to there will be more data traffic generated than required.

By the way I have another general question regarding schema - I will create a separate post for it.

Best regards
Andreas

Reply all
Reply to author
Forward
0 new messages