Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.5 KB

File metadata and controls

44 lines (30 loc) · 1.5 KB

RecursiveSwaggerSchemaParser

Swagger schema contains nested model definitions which in turn could contain other nested models. This library is created to parse all these the nested responses for a given path and HTTP Method and store it in a HashMap.

Initialize the parser swagger json contract path:

SwaggerSchemaParser swaggerSchemaParser = new SwaggerSchemaParser();
swaggerSchemaParser.initializeParser("http://petstore.swagger.io/v2/swagger.json");

Parse a response:

Sample:
HashMap<String, HashMap<String, String>> parsedResponse= swaggerSchemaParser.parseResponse("/pet/findByStatus", HttpMethod.GET,ResponseType.OK);
parseResponse(String path, HTTPMethod httpMethod, ResponseType responseType):
  • path

    The sub path that needs to be parsed.(Required)

  • HTTPMethod:

    Can be GET,PUT,POST or DELETE.(Required)

  • ResponseType:

    This specifies the HTTPResponse status we are looking for. Can be one of the following:(Optional. Default is All)

    • OK("200"),
    • NOT_FOUND("404"),
    • BAD_REQUEST("400"),
    • INTERNAL_SERVER_ERROR("500"),
    • NOT_IMPLEMENTED("502"),
    • BAD_GATEWAY("502"),
    • SERVICE_UNAVAILABLE("503"),
    • All("All") : This will return all responses that are returned by swagger.

License

GNU Public License version 3.0 RecursiveSwaggerSchemaParser is released under GNU Public License version 3.0