Class OpenAPIConverter

java.lang.Object
org.mockserver.openapi.OpenAPIConverter

public class OpenAPIConverter extends Object
  • Constructor Details

  • Method Details

    • buildExpectations

      public List<Expectation> buildExpectations(String specUrlOrPayload, Map<String,Object> operationsAndResponses)
    • buildExampleRequests

      public Map<String,HttpRequest> buildExampleRequests(String specUrlOrPayload)
      Builds a concrete example HttpRequest for each path operation in the spec, populating example path, query, header, and cookie parameter values (and a request body where the operation declares one) via the shared OpenApiParameterExamples helper.

      This is additive and independent of buildExpectations(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>): that method emits an OpenAPIDefinition matcher (which carries no concrete parameter values), whereas this method produces realised example requests for documentation, preview, replay seeding, and client/contract-test scaffolding. Webhook operations are excluded because they are not directly callable as path requests.

      Returns:
      a map of operationId to its example HttpRequest
    • buildExampleRequests

      public Map<String,HttpRequest> buildExampleRequests(String specUrlOrPayload, Map<String,Object> operationsAndResponses)
    • buildExpectations

      public List<Expectation> buildExpectations(String specUrlOrPayload, Map<String,Object> operationsAndResponses, String contextPathPrefix)
    • isJsonContentType

      public static boolean isJsonContentType(String contentType)
    • isXmlContentType

      public static boolean isXmlContentType(String contentType)
      True when the content type denotes XML — application/xml, text/xml, or any media type with a +xml structured-syntax suffix (e.g. application/atom+xml). Used to route a generated example through XmlExampleSerializer so an XML response yields a real XML body rather than a JSON-shaped string.