Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reference in parameters is not compiled to md at all. #20

Closed
astsiatsko opened this issue May 29, 2017 · 3 comments
Closed

reference in parameters is not compiled to md at all. #20

astsiatsko opened this issue May 29, 2017 · 3 comments

Comments

@astsiatsko
Copy link

I have the following json file downloaded from swagger online editor:

{
    "swagger": "2.0",
    "info": {
        "title": "Livechat API",
        "description": "description",
        "version": "1.0.0"
    },
    "host": "example.com",
    "schemes": [
        "https"
    ],
    "basePath": "/examplewebhook/",
    "produces": [
        "application/json"
    ],
    "consumes": [
        "application/x-www-form-urlencoded"
    ],
    "paths": {
        "/receive": {
            "post": {
                "summary": "Accept incoming webhook event",
                "description": "This endpoint is being triggered every time someone replies in custom livechat software",
                "parameters": [
                    {
                        "name": "body",
                        "in": "body",
                        "schema": {
                            "$ref": "#/definitions/Request"
                        }
                    },
                 ],
                "tags": [
                    "Livechat"
                ],
                "responses": {
                    "200": {
                        "description": "An array of kb records",
                        "schema": {
                            "$ref": "#/definitions/Success"
                        }
                    },
                    "400": {
                        "description": "Validation errors",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "Message":{
          "type":"object",
          "required":["date","responder","messageText"],
          "properties":{
              "date" : {
              "type" : "string",
              "description": "Date of the message"
            },
             "responder" : {
              "type" : "string",
              "description": "Responder of the message. The type of user who created a message. ROBOT or USER"
            },
             "messageText" : {
              "type" : "string",
              "description": "Text of the message"
            },
          }
        },
        "Request":{
          "required":["sessionId","token","type"],
          "properties":{
            "sessionId" : {
              "type" : "string",
              "description": "ID of the session to send message to"
            },
            "token":{
               "description": "desc",
               "type": "string"
            },
            "type":{
              "description": "Type of the livechat event. May be MESSAGE,ANNOUNCE_ENTER, ANNOUNCE_EXIT",
              "type": "string"
            },
            "jsonLog":{
              "type":"object",
              "description":"Interaction log of the session, this object will be triggered on enter event and will be empty on exit or message event",
              "properties":{
                "sessionId":{
                  "type":"string",
                  "description":"ID of the current livechat session"
                },
                "integrationId":{
                  "type":"string",
                  "description":"ID of the integration"
                },
                "email":{
                  "type":"string",
                  "description":"email that associated with the current session"
                },
                "userAgent":{
                  "type":"string",
                  "description":"User agent of the client, associated with the session. Not applicable for Facebook integration"
                },
                "ipAddress":{
                  "type":"string",
                  "description": "IP address of the client, associated with the session. Not applicable for Facebook integration"
                },
                "messages":{
                  "type":"array",
                  "description":"Message logs",
                  "items":{
                    "$ref": "#/definitions/Message"
                  }
                }
              }
            }
          }
        },
        "Error": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                },
                "error": {
                    "type": "string"
                }
            }
        },
        "Success": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                }
            }
        }
    }
}

And I run the following command:

widdershins webhook.html -o webhook.html.md

But, there's absolutely no reference to
'Request' definition or any other definition, except those in responses. Why? I mean in md file. When I compile it to slate and html I get no any reference to POST data that should be sent to webhook. I don't understand why. Please help asap. Thanks

Regards

@astsiatsko
Copy link
Author

PS. This schema is pretty valid in swagger.

@MikeRalphson
Copy link
Contributor

Hi @astsiatsko I believe the problem is that your API definition only has a consumes of application/x-www-form-urlencoded, which means body parameters are sent as simple key:value pairs in the POST request, but with no information as to how that body parameter should be structured.

I would expect a body parameter to have a related consumes (at operation or root level) of `application/json', 'text/x-yaml', 'application/xml' or some other structured format.

Can you let me know if application/x-www-form-urlencoded really is the correct / working content-type for your POST request? There is a related PR (#15) but at the moment I am still unconvinced it is correct to merge that change.

Your Request definition is also missing a "type": "object" - if you add this and a structured consumes content-type, then the Request body parameter and all code-samples look correct to me.

MikeRalphson added a commit that referenced this issue May 30, 2017
@MikeRalphson
Copy link
Contributor

This is fixed in v2.0.2. The body parameters are handled in a different way, and the missing type: object in schema definitions is patched automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants