Hi,

I am using swagger UI with Grizzly Http Server. 
I have used Bean Config to configure Swagger:

final ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner();
            scanner.setResourcePackage("ng.auth.oauth2");
            ScannerFactory.setScanner(scanner);
            ClassReaders.setReader(new DefaultJaxrsApiReader());
            
            beanConfig.setVersion("1.0");
            beanConfig.setResourcePackage("ng.auth.oauth2");
            beanConfig.setBasePath(BASE_URI + port+NG_API_ROUTE);
            beanConfig.setDescription("Hello OAuth2.0");
            beanConfig.setTitle("Hello OAuth API");
            beanConfig.setScan(true);
            beanConfig.setApiReader("JerseyApiReader");
            
            return beanConfig;

Everything is fine , but i am not able to get BeanParam as headers . Find 
the API below:

@POST
    @Path("/login")
    @Produces({"application/json"}) 
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "User Login",notes = "User session is 
created.",response 
= LoginResponse.class)
    @ApiResponses(value = {
        @ApiResponse(code = 200, message = "OK",response = LoginResponse.
class),
        @ApiResponse(code = 400, message = "invalid_request",response = 
ErrorResponse.class),
        @ApiResponse(code = 500, message = "server_error",response = 
ErrorResponse.class)})
    
    public Response getFormRefreshToken( @ApiParam(value = 
"OAuthRequestObject", required = true)  
OAuthRequest oauthRTParam ,    * @BeanParam OAuthHeader oauthheaderParam*  ) 
    {
        try{
                
            /***STUFF***/
            return Response.status(200).entity(resp).build();
        }
    
        catch(Exception ee){
           
            return Response.status(503).entity(new ErrorResponse("503",
OAuthErrorCode.server_error,OAuthErrorDesc.server_down,ee)).build();
        }
    }

OAuthHeader Param show as below in json:


{
  "apiVersion": "1.0",
  "swaggerVersion": "1.2",
  "basePath": "http://0.0.0.0:9997/ng";,
  "resourcePath": "/oauth2",
  "apis": [
    {
      "path": "/oauth2/login",
      "operations": [
        {
          "method": "POST",
          "summary": "User Login",
          "notes": "User session is created.",
          "type": "LoginResponse",
          "nickname": "getFormRefreshToken",
          "produces": [
            "application/json"
          ],
          "consumes": [
            "application/json"
          ],
          "parameters": [
            {
              "name": "body",
              "description": "OAuthRequestObject",
              "required": true,
              "type": "OAuthRequest",
              "paramType": "body"
            },
            {
              "name": "body",
              "required": false,
              "type": "OAuthHeader",
              "paramType": "body"
            }
          ],
          "responseMessages": [
            {
              "code": 200,
              "message": "OK",
              "responseModel": "LoginResponse"
            },
            {
              "code": 400,
              "message": "invalid_request",
              "responseModel": "ErrorResponse"
            },
            {
              "code": 500,
              "message": "server_error",
              "responseModel": "ErrorResponse"
            }
          ]
        }
      ]
    }
  ],
  "models": {
    "OAuthRequest": {
      "id": "OAuthRequest",
      "properties": {
        "update_session": {
          "type": "string"
        },
        "refresh_token": {
          "type": "string"
        },
        "scope": {
          "type": "integer",
          "format": "int32"
        },
        "user_context": {
          "type": "string"
        },
        "ip": {
          "type": "string"
        },
        "createdDeviceId": {
          "type": "string"
        },
        "tp": {
          "$ref": "Timestamp"
        },
        "sanitizedContext": {
          "type": "string"
        },
        "app_id": {
          "type": "string"
        }
      }
    },
    "OAuthHeader": {
      "id": "OAuthHeader",
      "properties": {
        "device_type": {
          "type": "string"
        },
        "tp": {
          "$ref": "Timestamp"
        },
        "accessToken": {
          "type": "string"
        },
        "device_id": {
          "type": "string"
        },
        "userAgent": {
          "type": "string"
        },
        "resid": {
          "type": "string"
        }
      }
    },
    "ErrorResponse": {
      "id": "ErrorResponse",
      "properties": {
        "code": {
          "type": "string"
        },
        "error": {
          "type": "string"
        },
        "error_description": {
          "type": "string"
        },
        "errorObject": {
          "$ref": "Exception"
        }
      }
    },
    "Timestamp": {
      "id": "Timestamp",
      "properties": {
        "time": {
          "type": "integer",
          "format": "int64"
        },
        "nanos": {
          "type": "integer",
          "format": "int32"
        },
        "date": {
          "type": "integer",
          "format": "int32"
        },
        "hours": {
          "type": "integer",
          "format": "int32"
        },
        "minutes": {
          "type": "integer",
          "format": "int32"
        },
        "month": {
          "type": "integer",
          "format": "int32"
        },
        "seconds": {
          "type": "integer",
          "format": "int32"
        },
        "year": {
          "type": "integer",
          "format": "int32"
        },
        "day": {
          "type": "integer",
          "format": "int32"
        },
        "timezoneOffset": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "LoginResponse": {
      "id": "LoginResponse",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "token_type": {
          "type": "string"
        },
        "refresh_token": {
          "type": "string"
        }
      }
    }
  }
}

Please find below my Bean Param Class:



import java.sql.Timestamp;
import java.util.Calendar;

import javax.ws.rs.HeaderParam;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class OAuthHeader {
    
        
    @HeaderParam("Auth") 
    String accessToken;
    
    @HeaderParam("device_id") 
    String device_id;
    
    @HeaderParam("User-Agent") 
    String userAgent;
    
    @HeaderParam("resid") 
    String resid;    
    
    @HeaderParam("device_type") 
    String device_type;
    
    
    public OAuthHeader() {
        
    }

    
    public OAuthHeader(String accessToken, String device_id, String 
userAgent, String resid,
            String device_type) {
        super();
        this.accessToken = accessToken;
        this.device_id = device_id;
        this.userAgent = userAgent;
        this.resid = resid;
        this.device_type = device_type;
        
    }


   public String getAccessToken() {
        return accessToken;
    }

    public String getDevice_id() {
        return device_id;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public String getDevice_type() {
        return device_type;
    }

    public void setDevice_id(String device_id) {
        this.device_id = device_id;
    }

    public String getResid() {
        return resid;
    }

    public void setResid(String resid) {
        this.resid = resid;
    }
    
    

}
 
I have also attached my projects pom.xml

Please help!
I am stuck , and i have looked into so many links to find a solution but 
nothing worked so far, 
Also i tried mentioning API  Implicit Params , but then code throws 
exceptions as bean class is empty.



-- 
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.

Attachment: pom.xml
Description: XML document

Reply via email to