Generated Swagger / OpenAPI Spec Is Invalid

I’ve tried to load the Swagger JSON but keep getting a failure:

Failed to resolve Swagger from : Failed to expand document: Failed to expand path /form/{parent-uuid}/resource: Failed to expand POST operation: Failed to expand 201 response: Failed to resolve response schema reference #/definitions/FormResourceGet: object has no key “FormResourceGet”

After checking the file, loaded from https://demo.openmrs.org/openmrs/module/webservices/rest/swagger.json, I’ve verified that there are no JSON References that would pull it in and it’s not declared in the definitions.

Any ideas?

Do you mind sharing the exact steps i would need to reproduce this locally?

Hello Daniel,

The steps are tricky because it’s using code from go-openapi. The easiest way to see what’s wrong is to download the JSON file and load it the Swagger editor at http://editor.swagger.io/. The catch is that if you try and save the JSON Swagger from https://demo.openmrs.org/openmrs/module/webservices/rest/swagger.json you need to be sure your browser doesn’t add any cruft. You can hand remove it if it does (this is because the mime type is reported as HTML on that link I believe). When it’s loaded in the editor (either via copy/paste or loading a file) you will see a number of validation errors in the editor. Sorry if it seems obtuse but if you need more help, let me know.

Al

What are you generally trying to accomplish? Are you working on a ticket?

I’m trying to generate code in the Go programming language for the Swagger. The tool we’ve written will parse the swagger and generate the code. The fact that the Swagger is invalid means that code that uses the swagger will fail (like my case). I’m not working on a ticket…I’m more likely to be a person opening a ticket actually.

Thanks!

Oh i see! Then go ahead and open the ticket. :smile:

OK, I just wanted to run it by here first to make sure I wasn’t missing something.

Thanks,

Al

That was very wise of you! :slight_smile:

@alskiontheweb, will you post a link to the issue here once you’ve created it?

cc @gayanw

@alskiontheweb Your issue will be resolved once this issue is being fixed: RESTWS-562. So you may not need to open a new issue.

@dkayiwa Could you mark it as ready for work?

Done! :smile:

I saw that one and wasn’t sure it applied. This is a completely missing type from the Swagger where as it seems the bug is more about the low level types (integer, boolean, etc). Should I add a note to it perhaps?

Why not? …