cancel
Showing results for 
Search instead for 
Did you mean: 

Malformed or unreadable swagger supplied

SOLVED
Highlighted
Occasional Contributor

Malformed or unreadable swagger supplied

My API definition passes validation in the editor and I can't see anything obviously wrong with it.  However, there's a big red "Invalid" message at the top of the page and it prevents me from doing code generation.  The API can be found here:

https://app.swaggerhub.com/api/myaccount/BNA_Temp/v1

 

Two questions:

 

First, can you help find out what's wrong?

Second, are there any tools or techniques that I can use to track down this kind of issue myself?

 

Thanks for any help.

David 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Malformed or unreadable swagger supplied

Hi David,

 

The issue is that in multiple places, when you define an array, you set the `items` value as an array as well, where it should be an object. While JSON Schema does support both, the Swagger spec only allows for objects as values.

 

For example,

 

  RecommendationsResponse:
    type: array
    items:
      - $ref: '#/definitions/Recommendation'

Should be:

  RecommendationsResponse:
    type: array
    items:
      $ref: '#/definitions/Recommendation'

Once you make all those modifications, it should work as expected.

 

As for your second question - Since the spec uses a variant of JSON Schema, some issues are harder to track. We're constantly trying to improve our tools, and I'll open a ticket internally to address this specific issue.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Re: Malformed or unreadable swagger supplied

Hi David,

 

The issue is that in multiple places, when you define an array, you set the `items` value as an array as well, where it should be an object. While JSON Schema does support both, the Swagger spec only allows for objects as values.

 

For example,

 

  RecommendationsResponse:
    type: array
    items:
      - $ref: '#/definitions/Recommendation'

Should be:

  RecommendationsResponse:
    type: array
    items:
      $ref: '#/definitions/Recommendation'

Once you make all those modifications, it should work as expected.

 

As for your second question - Since the spec uses a variant of JSON Schema, some issues are harder to track. We're constantly trying to improve our tools, and I'll open a ticket internally to address this specific issue.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

Highlighted
Occasional Contributor

Re: Malformed or unreadable swagger supplied

Thanks for the fast response - that fixed my problem.

New Here?
Join us and watch the welcome video:
Announcements