By not specifying a schema for the response, you’re pretty much saying the 
response is empty.

Now, describing the response for HTMl with json schema is not really doable.

In that case, just specify that the schema is {}, pretty much saying anything 
goes, but it still suggests there’s a response body 

 

expected.

 

From: <[email protected]> on behalf of Shachar Romi 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Saturday, 13 August 2016 at 08:43
To: Swagger <[email protected]>
Subject: How to provide example value to a Response Body of content-type: 
text/html in Swagger

 

Hello, 

 

I have an API call which responds 200 OK and returns an HTML. I would like to 
add this to my API documentation

(especially since i validate it using dredd and unless i provide it with the 
expected response body the test fails). How

would i do this in Swagger?

 

--- More details ---

My Response to an API call is 200 OK and with a one line Response Body:

<html><body>You are being <a 
href="https://my.domain.com/users/sign_in";>redirected</a>.</body></html>

 

I can easily define the Response Body in Blueprint in the following form:

 

>    + Response 302 (text/html; charset=utf-8)

>    

>        + Body

>        

>                <html><body>You are being <a 
> href="https://my.domain.com/users/sign_in";>redirected</a>.</body></html>

 

But i'm not sure how to do this in Swagger. Almost all examples i can find are 
for application/json responses (understandably) and i'm having trouble

guessing the correct syntax for this kind of response.

 

The relevant swagger text in my document is this (so far without specifying the 
response body, so with an empty body dredd

fails because the response body should be <html><body>You are being <a 
href="https://my.domain.com/users/sign_in";>redirected</a>.</body></html>):

 

# this is my API spec in YAML

swagger: '2.0'

info:

  title: My API (Swagger)

  description: blablabla

  version: "1.0.0"

# the domain of the service

host: my.domain.com

# array of all schemes that your API supports

schemes:

  - https

# will be prefixed to all paths

basePath: /

produces:

  - application/json; charset=utf-8

paths:

  /users/password:

    post:

      summary: Password Reset

      description: |

        Handles Reset password for existing user.

      consumes:

        - application/x-www-form-urlencoded

      produces:

        - text/html; charset=utf-8

      parameters:

        - name: "user[email]"

          description: email

          in: formData

          required: true

          type: string

          default: "[email protected]"

      tags:

        - Reset Password

      responses:

        200:

          description: Success

 

Please comment if you have any suggestions on this. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to