Apache Camel: implicit headers (#14674)

* Apache Camel: fix implicit headers

* ./mvnw clean package
  ./bin/generate-samples.sh
  ./bin/utils/export_docs_generators.sh

* Q

* Created samples/openapi3/client/3_0_3_unit_test/python/test/.gitempty

* update samples

---------

Co-authored-by: Giacomo Carnevale <gcarnevale@imolainformatica.it>
This commit is contained in:
William Cheng 2023-02-11 23:48:55 +08:00 committed by GitHub
parent b6abace9dc
commit d7a2e4a293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 23 deletions

View File

@ -15,3 +15,4 @@ additionalProperties:
camelUseDefaultValidationErrorProcessor: true
camelRestClientRequestValidation: true
camelSecurityDefinitions: true
implicitHeaders: true

View File

@ -75,7 +75,13 @@ public class {{classname}} extends RouteBuilder {
.type(RestParamType.header)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/headerParams}}{{#bodyParams}}
.endParam(){{/headerParams}}{{#implicitHeadersParams}}
.param()
.name("{{baseName}}")
.type(RestParamType.header)
.required({{required}}){{#description}}
.description("{{{.}}}"){{/description}}
.endParam(){{/implicitHeadersParams}}{{#bodyParams}}
.param()
.name("{{paramName}}")
.type(RestParamType.body)

View File

@ -39,8 +39,8 @@ Do not edit the class manually.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework.boot.version>2.6.2</org.springframework.boot.version>
<org.apache.camel.version>3.14.0</org.apache.camel.version>
<org.springframework.boot.version>2.7.8</org.springframework.boot.version>
<org.apache.camel.version>3.20.1</org.apache.camel.version>
</properties>
<dependencyManagement>
@ -74,10 +74,9 @@ Do not edit the class manually.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
@ -117,7 +116,7 @@ Do not edit the class manually.
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
<version>0.2.4</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
@ -128,19 +127,19 @@ Do not edit the class manually.
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.7</version>
<version>2.2.8</version>
</dependency>
{{/oas3}}
{{#jackson}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.0</version>
<version>2.14.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.13.0</version>
<version>2.14.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>

View File

@ -14,6 +14,8 @@ public class RestConfiguration extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.scheme("{{scheme}}")
.host("{{host}}")
.component("{{camelRestComponent}}")
.bindingMode(RestBindingMode.{{camelRestBindingMode}}){{#camelDataformatProperties}}
.dataFormatProperty("{{key}}", "{{value}}"){{/camelDataformatProperties}}

View File

@ -28,7 +28,7 @@ public class {{classname}}RoutesImpl extends RouteBuilder {
.log(LoggingLevel.INFO, "HEADERS: ${headers}"){{#hasProduces}}{{#examples}}{{#-first}}{{^isArray}}{{^isMap}}{{^isPrimitiveType}}
.setBody(constant({{>exampleString}}))
.unmarshal().json(JsonLibrary.Jackson, {{returnType}}.class){{/isPrimitiveType}}{{/isMap}}{{/isArray}}{{#isArray}}
.setBody(constant({{>exampleStringArray}}))
.setBody(constant({{>exampleString}}))
.unmarshal().json(JsonLibrary.Jackson, {{returnBaseType}}[].class){{/isArray}}{{/-first}}{{/examples}}{{/hasProduces}};{{/operation}}{{/operations}}
}
}

View File

@ -39,8 +39,8 @@ Do not edit the class manually.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework.boot.version>2.6.2</org.springframework.boot.version>
<org.apache.camel.version>3.14.0</org.apache.camel.version>
<org.springframework.boot.version>2.7.8</org.springframework.boot.version>
<org.apache.camel.version>3.20.1</org.apache.camel.version>
</properties>
<dependencyManagement>
@ -74,10 +74,9 @@ Do not edit the class manually.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
@ -117,7 +116,7 @@ Do not edit the class manually.
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
<version>0.2.4</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
@ -127,17 +126,17 @@ Do not edit the class manually.
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.7</version>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.0</version>
<version>2.14.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.13.0</version>
<version>2.14.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>

View File

@ -14,6 +14,8 @@ public class RestConfiguration extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.scheme("http")
.host("petstore.swagger.io")
.component("servlet")
.bindingMode(RestBindingMode.auto)
.dataFormatProperty("json.out.disableFeatures", "WRITE_DATES_AS_TIMESTAMPS")

View File

@ -74,7 +74,7 @@ public class PetApi extends RouteBuilder {
.description("Pet id to delete")
.endParam()
.param()
.name("apiKey")
.name("api_key")
.type(RestParamType.header)
.required(false)
.endParam()

View File

@ -48,7 +48,7 @@ public class PetApiRoutesImpl extends RouteBuilder {
.log(LoggingLevel.INFO, "BODY TYPE: ${body.getClass().getName()}")
.end()
.log(LoggingLevel.INFO, "HEADERS: ${headers}")
.setBody(constant("[[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]]"))
.setBody(constant("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]"))
.unmarshal().json(JsonLibrary.Jackson, Pet[].class);
/**
GET /pet/findByTags : Finds Pets by tags
@ -60,7 +60,7 @@ public class PetApiRoutesImpl extends RouteBuilder {
.log(LoggingLevel.INFO, "BODY TYPE: ${body.getClass().getName()}")
.end()
.log(LoggingLevel.INFO, "HEADERS: ${headers}")
.setBody(constant("[[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]]"))
.setBody(constant("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]"))
.unmarshal().json(JsonLibrary.Jackson, Pet[].class);
/**
GET /pet/{petId} : Find pet by ID