This documentation is for WSO2 API Manager 1.7.0 View documentation for the latest release.
Page Comparison - Adding Documentation Using Swagger (v.4 vs v.5) - API Manager 1.7.0 - WSO2 Documentation

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. In the API Publisher, go to the Doc tab of FindFeeds API to see its API definition. Click Edit Content. PhoneVerify API and click Edit Content under Swagger Documentation.
    Image Added
  2. API definition contains the JSON representation of the API. You can easily modify existing content, add/remove elements, change paths and parameters etc. using the JSON editor. A sample API definition is given below:

    Code Block
    {
        "apiVersion": "1.0.0",
        "swaggerVersion": "1.1",
        "basePath": "http://10.100.5.123:8280",
        "resourcePath": "PhoneVerification",
        "apis": [
            {
                "path": "/phoneverify/1.0.0/CheckPhoneNumber",
                "description": "no-info",
                "operations": [
    
    
                    {
    
    
                        "httpMethod": "GET",
    
    
                        "summary": "PhoneVerify",
    
    
                        "nickname": "getDetails",
    
    
                        "parameters": [
    
    
                            {
    
    
                                "name": "Authorization",
    
    
                                "description": "Access Token",
    
    
                                "paramType": "header",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            },
    
    
                            {
    
    
                                "name": "Payload",
    
    
                                "description": "Request Payload",
    
    
                                "paramType": "body",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            }
    
    
                        ]
    
    
                    },
    
    
                    {
    
    
                        "httpMethod": "PUT",
    
    
                        "summary": "no-info",
    
    
                        "nickname": "no-info",
    
    
                        "parameters": [
    
    
                            {
    
    
                                "name": "Authorization",
    
    
                                "description": "Access Token",
    
    
                                "paramType": "header",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            },
    
    
                            {
    
    
                                "name": "Payload",
    
    
                                "description": "Request Payload",
    
    
                                "paramType": "body",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            }
    
    
                        ]
    
    
                    },
    
    
                    {
    
    
                        "httpMethod": "POST",
    
    
                        "summary": "no-info",
    
    
                        "nickname": "no-info",
    
    
                        "parameters": [
    
    
                            {
    
    
                                "name": "Authorization",
    
    
                                "description": "Access Token",
    
    
                                "paramType": "header",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            },
    
    
                            {
    
    
                                "name": "Payload",
    
    
                                "description": "Request Payload",
    
    
                                "paramType": "body",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            }
    
    
                        ]
    
    
                    },
    
    
                    {
    
    
                        "httpMethod": "DELETE",
    
    
                        "summary": "no-info",
    
    
                        "nickname": "no-info",
    
    
                        "parameters": [
    
    
                            {
    
    
                                "name": "Authorization",
    
    
                                "description": "Access Token",
    
    
                                "paramType": "header",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            },
    
    
                            {
    
    
                                "name": "Query Parameters",
    
    
                                "description": "Request Query Parameters",
    
    
                                "paramType": "body",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            }
    
    
                        ]
    
    
                    },
    
    
                    {
    
    
                        "httpMethod": "OPTIONS",
    
    
                        "summary": "no-info",
    
    
                        "nickname": "no-info",
    
    
                        "parameters": [
    
    
                            {
    
    
                                "name": "Payload",
    
    
                                "description": "Request Payload",
    
    
                                "paramType": "body",
    
    
                                "required": true,
    
    
                                "allowMultiple": false,
    
    
                                "dataType": "String"
    
    
                            }
    
    
                        ]
    
    
                    }
    
    
                ]
    
    
            }
    
    
        ]
    
    
    }
                
    Info
  3. There are Two ways to modify the API Defnitiondefinition. You can either use the Text Editor given, or the graphical tree editor.

    By default, all the POST and PUT operations have the Payload parameter, which you can use to send any payload when invoking the API. The GET, DELETE operations have Query parameters, which you can use to send URL-appended parameters (ex: v=2&length=200). You can also add named parameters. For example, to modify the path of the API created above with a parameter, edit the path and add the relevant parameter.

    Let's say that you want to send a query parameter called 'v' in the GET request of top_rated resource. The screenshot below shows path modified with a parameter. Also, the default Query Parameter is changed to a parameter called v .

    Text Editor

    You can just modify the JSON content according to Swagger Specification.

    Graphical Editor

    Shown below is an example of the graphical editor. To add new elements, click Add New Value and provide the value. To delete elements, delete the value of Key. For example, if you delete the Key value named description, that element will be deleted. Also be sure to modify descriptions, notes, summary on each of the operations.

     

  4. Once the modifications are done, save.

  5. Log in to the API Store and click on GET operation to expand it. There you can enter the parameters and try it out.

...