Hello all,
I am developing my own connector with an action that should return html text by id using api method.
My connector action is described as following:
paths:
/getTemplate:
get:
produces: [application/json, text/html]
parameters:
- {name: id, in: query, description: Template ID, required: true, type: string}
responses:
default:
description: default
schema:
type: object
properties:
template: {type: string, description: template, title: '', format: html}
If I pass the template as 'text/html' my flow failed with error 'The API operation "getTemplate" requires the property 'body' to be of type 'Object' but is of type 'String'.'
If I pass the template as application/json, I convert the HTML to base64 string and put it to JSON object, but in this way I get the same base64 string (not HTML) in response. My JSON object looks like the following:
{ 'template': '<base64>' }
How I can pass and get HTML text in the connector action?
Thank you.
Regards.
Your schema definition should match the response payload.
If you API returns the HTML payload directly, you will describe it as:
schema: { type: string}, or
schema: { type: string, format: binary } // if you think the payload are not text
If your API returns the HTML payload wrapped in JSON, like below:
{
"template": "<html>....</html>"
}
Then your schema definition would be:
schema: {
type: object,
properties: {
template: { type: string }
}
}
Finally, If your API returns the HTML payload wrapped in JSON and encoded, like below:
{
"template": "base64encoded HTML string"
}
Then your schema definition would be:
schema: {
type: object,
properties: {
template: { type: string, format: byte }
}
}
Hope this clarifies.
We also provide an experience to generate the schemas from sample payload.