Generate sample request and responses from Swagger Definition

梦想与她 提交于 2019-12-13 13:13:15

问题


I want to generate a sample request and response from a swagger definition file(yaml/json). The intent is to stub out these APIs.

Unfortunately I do not have admin rights to install any of the server frameworks listed in the generate server list of the swagger editor. I've also tried mocking it with soapui(5.x) and ready api , but both of them are not able to resolve the schema references within the response objects of the definition file - Eg:

"responses": {
          "200": {
            "description": "pet response",
            "schema": {
              "$ref": "**#/definitions/Pet**"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "**#/definitions/ErrorModel**"
            }
          }

Is there a simple way to generate the mock requests and responses from the definition?

Thanks,


回答1:


I think this (http://apigee.com/about/blog/developer/swagger-test-templates-test-your-apis) is what you're looking for.

It goes through a list of products (Handlebars JS, Mocha JS, Commander JS) and how to orchestrate them to get some test code.



来源:https://stackoverflow.com/questions/32430367/generate-sample-request-and-responses-from-swagger-definition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!