Clone Tools
  • last updated a few minutes ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
CAMEL-10932 REST Swagger component

This includes the initial implementation of the `rest-swagger` component

that allows for a higher level abstraction over the REST API usage from

other Camel components that implement the `RestProducerFactory` SPI

combined with Swagger (Open API) specifications.

The most simple usage would be:

to("rest-swagger:getPetById")

Which would pick up the Swagger specification from `swagger.json` and

try to find a single component that implements the `RestProducerFactory`

SPI and invoke the `getPetById` operation.

Other way of using this component could be:

to("rest-swagger:http://petstore.swagger.io/v2/swagger.json#getPetById")

That loads the Swagger specification from the

`http://petstore.swagger.io/v2/swagger.json` URL and invokes the

`getPetById` operation.

More concise way of configuring would be to configure most properties

on the component add it to CamelContext, and use only `operationId` path

parameter when triggering the exchange:

// add `petstore` component to the CamelContext

RestSwaggerComponent petstore =

new RestSwaggerComponent(camelContext);

petstore.setSpecificationUri("http://petstore.swagger.io/v2/swagger.json");

petstore.setComponentName("undertow");

camelContext.addComponent("petstore", petstore);

And then use `operationId` in endpoint definition:

ProducerTemplate template = camelContext.getProducerTemplate();

template.requestBodyAndHeaders("petstore:getPetById", null, "petId",

petId);

    • -0
    • +152
    ./RestSwaggerComponentTest.java
    • -0
    • +336
    ./RestSwaggerEndpointTest.java
    • -0
    • +66
    ./RestSwaggerEndpointUriParsingTest.java
    • -0
    • +50
    ./RestSwaggerHelperTest.java
  1. … 25 more files in changeset.