No Response when consuming a swagger.json with body object parameter

I am trying to consume a swagger.json file. This list below is a simplified version of the the real file. When I choose "Consume REST API..." - "Add all methods" for this file nothing will hapen, neither an import nor an error message will pop up.

But when I delete the lines

30 - name: body
31          in: body
32          required: true
33          schema:
34            $ref: '#/definitions/Request'

this will work. Does anyone have a clue?

Oh, I am not allowed to attach this swagger.json file in this question, so here is the content:

swagger: '2.0'
info:
  title: OutSystems TEST API
  description: OutSystems TEST API
  version: LTS - 1.0.0
schemes:
  - http
  - https
basePath: '/v1/'
produces:
  - application/json
securityDefinitions:
  AccessToken:
    type: apiKey
    description: |
      **X-Authorization: _token_**
    name: X-Authorization
    in: header
security:
  - AccessToken: []
paths:
  '/test/{id}':
    put:
      summary: Update test.
      description: Update existing test.
      consumes:
        - application/json
      parameters:
        - $ref: '#/parameters/PathTestId'
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Request'
      tags:
        - test
      responses:
        '200':
          description: Successful update of test.
          schema:
            $ref: '#/definitions/Response'
        '400':
          $ref: '#/responses/400'
        '401':
          $ref: '#/responses/401'
        '403':
          $ref: '#/responses/403'
        '404':
          $ref: '#/responses/404'
        '409':
          $ref: '#/responses/409'
        '500':
          $ref: '#/responses/500'
definitions:
  Request:
    type: object
    required:
      - name
    properties:
      name:
        type: string
        description: Name of test.
  Response:
    allOf:
      - $ref: '#/definitions/Request'
      - type: object
        properties:
          id:
            type: string
            description: Unique identifier of the test.
  Error:
    type: object
    properties:
      code:
        type: integer
        description: Error code
      message:
        type: string
        description: Message description.
parameters:
  PathTestId:
    name: id
    in: path
    type: integer
    required: true
    description: Id of the Test
  PathDeviceId:
    name: id
    in: path
    type: integer
    required: true
    description: Id of the  device
  PathQueueName:
    name: queuename
    in: path
    type: integer
    required: true
    description: Id of the  device
responses:
  '400':
    description: Bad request
    schema:
      $ref: '#/definitions/Error'
  '401':
    description: Authentication required
    schema:
      $ref: '#/definitions/Error'
  '403':
    description: Unauthorized access
    schema:
      $ref: '#/definitions/Error'
  '404':
    description: Not found
    schema:
      $ref: '#/definitions/Error'
  '409':
    description: Conflict
    schema:
      $ref: '#/definitions/Error'
  '500':
    description: Internal Server error
    schema:
      $ref: '#/definitions/Error'


Hi Martin,


I don't have any experience with Swagger files, but maybe 'body' is a reserved keyword or something, can you try renaming it instead of deleting it, and see what happens.  Just a shot in the dark...


Dorine

Hi Martin,

Did you try and validate the swagger file with an online tool like https://apitools.dev/swagger-parser/online/ ?

Maybe it will tell you what is wrong with the file.

Regards,

Daniel

1. Proposal Rename "body"
-> Sorry, no success

2. Online Tool
This one says everything is correct. Just like https://editor.swagger.io/ I I have worked with so far.

Hi Martin,

I didn't look closely at your swagger before, I just assumed you were generating it with Outsystems, but the API is not made with Outsystems, is it ?

So first maybe look at this : what you show in your post looks like YAML, not JSON.  I'm not sure the capability in Outsystems to read a swagger definition and turn it into a consumed api extends to swagger in yaml, for example, when opening file selection window, only has option for json.

Dorine

Hi Dorine,

yes, the API is not made with OutSystems, it's from a different System. It has some more methods, but I deleted most of it, just to leave one method to point out the problem parameter object body.

Yes, what I showed looks like YAML. In this forum we are allowed to attach OML-Files, but as I tried to attach my swagger.json file I got an error that this is not allowed. (I do not know why?) So instead of this I copied the API lines from my Swagger editor https://editor.swagger.io/ into my initial post.

Martin

Hi Martin,

not sure I understand, the actual definition file you are trying to do 'add all methods' with, does it contain yaml format ??  In that case, maybe try to convert it to json and try with that...  I don't think Outsystems can read YAML, when I try, I get this error :


If you are already using JSON, another reason could be that Outsystems parser can't deal with $ref ??  I tried a little test, taking a simplified version of your example yaml, replacing all $ref with the substituted value, and turning it into json, and Outsystems can work with that 

This is the json I tried with : 

{
"swagger": "2.0",
"info": {
  "title": "OutSystems TEST API",
  "description": "OutSystems TEST API",
  "version": "LTS - 1.0.0"
},
"schemes": [
  "http",
  "https"
],
"basePath": "/v1/",
"produces": [
  "application/json"
],
"securityDefinitions": {
  "AccessToken": {
    "type": "apiKey",
    "description": "**X-Authorization: _token_**\n",
    "name": "X-Authorization",
    "in": "header"
  }
},
"security": [
  {
    "AccessToken": []
  }
],
"paths": {
  "/test/{id}": {
    "put": {
      "summary": "Update test.",
      "description": "Update existing test.",
      "consumes": [
        "application/json"
      ],
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "type": "integer",
          "required": true,
          "description": "Id of the Test"
        },
        {
          "name": "body",
          "in": "body",
          "required": true,
          "schema": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of test."
            }
          }
        }
      }
    ],
    "tags": [
      "test"
    ],
    "responses": {
      "200": {
        "description": "Successful update of test."
        }
      }
    }
  }
}
}

And Outsystems is able to parse this :


Maybe something for you to explore ?

succes,

Dorine

Hi Dorine,

sorry for confusing with a yaml format. My Swagger Editor shows yaml format, which I saved in json format, that I tried to consume in OutSystems. I always tried to import JSON format. I would be better to post a JSON-Format here just like you did.

Your JSON works fine, also for me. Maybe it's about the $ref?

This one with $ref works:
{
  "swagger": "2.0",
  "info": {
    "title": "OutSystems TEST API",
    "description": "OutSystems TEST API",
    "version": "LTS - 1.0.0"
  },
  "schemes": [
    "http",
    "https"
  ],
  "basePath": "/v1/",
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "AccessToken": {
      "type": "apiKey",
      "description": "**X-Authorization: _token_**\n",
      "name": "X-Authorization",
      "in": "header"
    }
  },
  "security": [
    {
      "AccessToken": []
    }
  ],
  "paths": {
    "/test/{id}": {
      "put": {
        "summary": "Update test.",
        "description": "Update existing test.",
        "consumes": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "type": "integer",
            "required": true,
            "description": "Id of the Test"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Request"
            }
          }
        ],
        "tags": [
          "test"
        ],
        "responses": {
          "200": {
            "description": "Successful update of test."
          }
        }
      }
    }
  },
  "definitions": {
    "Request": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of test."
        }
      }
    }
  }
}


This one does not work:
{
  "swagger": "2.0",
  "info": {
    "title": "OutSystems TEST API",
    "description": "OutSystems TEST API",
    "version": "LTS - 1.0.0"
  },
  "schemes": [
    "http",
    "https"
  ],
  "basePath": "/v1/",
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "AccessToken": {
      "type": "apiKey",
      "description": "**X-Authorization: _token_**\n",
      "name": "X-Authorization",
      "in": "header"
    }
  },
  "security": [
    {
      "AccessToken": []
    }
  ],
  "paths": {
    "/test/{id}": {
      "put": {
        "summary": "Update test.",
        "description": "Update existing test.",
        "consumes": [
          "application/json"
        ],
        "parameters": [
          {
            "$ref": "#/parameters/PathTestId"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Request"
            }
          }
        ],
        "tags": [
          "test"
        ],
        "responses": {
          "200": {
            "description": "Successful update of test."
          }
        }
      }
    }
  },
  "definitions": {
    "Request": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of test."
        }
      }
    }
  },
  "parameters": {
    "PathTestId": {
      "name": "id",
      "in": "path",
      "type": "integer",
      "required": true,
      "description": "Id of the Test"
    }
  }
}

I' m not quite sure what to change in the swagger.json files (no error shown up in the Swagger Editor) because there are over 100 methods and over over 100 $refs.

I now try to replace on of the two $ref in the parameter part of the methods. 

Oke,

so having 100 methods kind of makes it appealing to be able to add all methods in one go :-)

And to be honest I expect from OutSystems an Swagger Import or an error message.