Class SwaggerHubClient

java.lang.Object
io.github.ludy87.swagger.swaggerhub.v2.client.SwaggerHubClient

public class SwaggerHubClient extends Object
Client for interacting with SwaggerHub API. This class provides methods to download and upload API definitions.
  • Constructor Details

    • SwaggerHubClient

      public SwaggerHubClient()
  • Method Details

    • create

      public static SwaggerHubClient create(String host, Integer port, String protocol, String token)
      Creates a SwaggerHubClient for public SwaggerHub instances.
      Parameters:
      host - the host of the SwaggerHub instance
      port - the port of the SwaggerHub instance
      protocol - the protocol (http or https)
      token - the authentication token
      Returns:
      a configured SwaggerHubClient instance
    • createOnPremise

      public static SwaggerHubClient createOnPremise(String host, Integer port, String protocol, String token, Boolean onPremise, String onPremiseAPISuffix)
      Creates a SwaggerHubClient for on-premise SwaggerHub instances.
      Parameters:
      host - the host of the SwaggerHub instance
      port - the port of the SwaggerHub instance
      protocol - the protocol (http or https)
      token - the authentication token
      onPremise - whether this is an on-premise instance
      onPremiseAPISuffix - the API suffix for on-premise instances
      Returns:
      a configured SwaggerHubClient instance
    • getDefinition

      public String getDefinition(SwaggerHubRequest swaggerHubRequest) throws org.gradle.api.GradleException
      Downloads the API definition from SwaggerHub.
      Parameters:
      swaggerHubRequest - the request containing API details
      Returns:
      the API definition as a string
      Throws:
      org.gradle.api.GradleException - if there is an error during the GET request
    • saveDefinition

      public void saveDefinition(SwaggerHubRequest swaggerHubRequest) throws org.gradle.api.GradleException
      Saves the API definition to SwaggerHub.
      Parameters:
      swaggerHubRequest - the request containing API details
      Throws:
      org.gradle.api.GradleException - if there is an error during the POST request
    • saveDefinitionPUT

      public void saveDefinitionPUT(SwaggerHubRequest swaggerHubRequest) throws org.gradle.api.GradleException
      Sets the default version for the API in SwaggerHub.
      Parameters:
      swaggerHubRequest - the request containing API details
      Throws:
      org.gradle.api.GradleException - if there is an error during the PUT request