Provided OpenAPI Spec is Invalid

OpenAPI spec provided from http://docs-local.appbond.com/ is invalid. It does not pass a linting and cannot be imported into Postman. Using OpenAPI Spec Validator, returns the following errors:

$ openapi-spec-validator ~/Downloads/swagger.json
{'content': {'application/json': {'type': 'object', 'example': {'aabbccdd': {'action': 'SetSpeed', 'icon': 'speed_3', 'argument': 3, 'name': 'High'}, '00112233': {'action': 'SetSpeed', 'icon': 'speed_1', 'argument': 1, 'name': 'Low'}, 'abcdef01': {'action': 'StartDimming', 'name': 'Dimmer', 'icon': 'dimmer'}}}}, 'description': 'Command list returned'} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['get']['properties']['responses']['patternProperties']['^([0-9X]{3})$']:
    {'oneOf': [{'$ref': '#/definitions/response'},
               {'$ref': '#/definitions/reference'}]}

On instance['paths']['/v2/devices/{device_id}/commands']['get']['responses']['200']:
    {'content': {'application/json': {'example': {'00112233': {'action': 'SetSpeed',
                                                               'argument': 1,
                                                               'icon': 'speed_1',
                                                               'name': 'Low'},
                                                  'aabbccdd': {'action': 'SetSpeed',
                                                               'argument': 3,
                                                               'icon': 'speed_3',
                                                               'name': 'High'},
                                                  'abcdef01': {'action': 'StartDimming',
                                                               'icon': 'dimmer',
                                                               'name': 'Dimmer'}},
                                      'type': 'object'}},
     'description': 'Command list returned'}

@feliperuhland can you comment here?

Hello @danmandle.

I’ll verify that validation error and make sure the ci build validate this before updating.

Thanks @merck

UPDATE: I create an issue for that #71.

1 Like

I already fixed spec issues, but we share components with other internal APIs, and I need to make sure I didn’t break anything else.

I’ll inform here about any update.

Thanks.

Is anyone able to spend a /tx PUT request to a device_id / command_id combo in Postman and get it to work?

Postman is throwing errors for me when traditional cURL works (with a -i or -v switch). Both of those switches cannot be provided in Postman.

Get it to actually issue the command to BOND Bridge and have the ceiling fan respond?
Yes (Windows x64 Postman v7.0.7).

Get Postman to stop complaining about the non-zero length of the 204 response?
No.

Try adding a header to the request called Content-Length with a value of 2.

1 Like

Yep! For some reason, it accepts that and works. Thanks!

1 Like

This is still giving an error when importing into Postman.

Hi @danmandle

I don’t use postman, but openapi_spec_validator is passing now. The pull request is ready and waiting for review.

I don’t have a date for the deployment, but I’ll inform here about any update.

I’m wondering what the latest is on this. It seems that the provided OpenAPI spec is still not valid, but for different reasons now:

Swagger schema validation failed. 
  Data does not match any schemas from 'oneOf' at #/paths//v2/token/patch/responses/200
Data does not match any schemas from 'oneOf' at #/paths//v2/token/patch/responses/200/content/application/json/schema
  Data does not match any schemas from 'oneOf' at #/content/application/json/schema/properties/locked
    No enum match for: int at #/properties/locked/type
    Missing required property: $ref at #/properties/locked
  Missing required property: $ref at #/content/application/json/schema
Missing required property: $ref at #/paths//v2/token/patch/responses/200
  Data does not match any schemas from 'oneOf' at #/paths//v2/token/patch/requestBody
Data does not match any schemas from 'oneOf' at #/paths//v2/token/patch/requestBody/content/application/json/schema
  Data does not match any schemas from 'oneOf' at #/content/application/json/schema/properties/locked
    No enum match for: int at #/properties/locked/type
    Missing required property: $ref at #/properties/locked
  Missing required property: $ref at #/content/application/json/schema
Missing required property: $ref at #/paths//v2/token/patch/requestBody

Can you comment what you use the spec for? Some kind of code generation?

I have been trying to use the spec to generate a client using swagger-codegen. I was eventually able to get it to work by manually modifying the downloaded swagger.json until there were no more errors.