khrt / Raisin

Raisin - a REST API micro framework for Perl 🐫 🐪
61 stars 30 forks source link

'Unexpected error' In the responses/default/descritption of swagger #28

Open jerowe opened 7 years ago

jerowe commented 7 years ago

Cool project!

I noticed when generating swagger I get an 'Unexpected Error'. How can I document the expected response in Raisin?

 {
      "get": {
        "consumes": [
          "application/x-yaml",
          "application/json"
        ],
        "operationId": "get_users__id",
        "responses": {
          "default": {
            "description": "Unexpected error"
          }
        },
        "tags": [
          "users"
        ],
        "produces": [
          "application/x-yaml",
          "application/json"
        ],
        "summary": "Show user",
        "description": "",
        "parameters": [
          {
            "type": "integer",
            "in": "path",
            "required": true,
            "description": "User ID",
            "format": "int32",
            "name": "id"
          }
        ]
      },

Thanks!

khrt commented 7 years ago

Jillian,

currently you can't set response object manually but Raisin can generate one (a success one) automatically, for that you need to use Raisin::Entity to describe the response object.

See https://github.com/khrt/Raisin/blob/master/lib/Raisin/Plugin/Swagger.pm#L219 and https://github.com/khrt/Raisin/blob/master/examples/music-app/script/music_app_dbix.psgi#L46 and https://metacpan.org/pod/Raisin::Entity

I'll add it to my plan and try to implement with the next release.