Johan Karlsson created CAMEL-12420:
--------------------------------------
Summary: Swagger definition
Key: CAMEL-12420
URL: https://issues.apache.org/jira/browse/CAMEL-12420
Project: Camel
Issue Type: Bug
Components: camel-swagger
Affects Versions: 2.21.0
Environment:
{code:xml}
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
<camel.version>2.21.0</camel.version>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java-starter</artifactId>
<version>${camel.version}</version>
</dependency>
{code}
{code:sh}
java -version
openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
{code}
Reporter: Johan Karlsson
I've created two gists.
[This first
gist|https://gist.github.com/hochas/10e1f65531211672de03d018e42447df] is
generated by _camel-swagger-java:2.21.0_ and is broken
Copy the contents and paste into the [Swagger
Editor|http://editor.swagger.io/]. See field _identification_ under
_/classifier_ which according to the editor is broken.
[This second
gist](https://gist.github.com/hochas/1218ef7a14da509f7079c1f5e098b53c) is
modified by hand and displays the field _identification_ as expected.
The difference is at [line
74|https://gist.github.com/hochas/1218ef7a14da509f7079c1f5e098b53c#file-camel-swagger-working-json-L74].
The enum type in the broken version, [line
76|https://gist.github.com/hochas/10e1f65531211672de03d018e42447df#file-camel-swagger-broken-json-L76],
should be inside the `items` object, according to [this
issue|https://github.com/swagger-api/swagger-ui/issues/4400] at swagger-ui.
This current behavior [seems to have been
correct|https://github.com/swagger-api/swagger-ui/issues/685] some time back.
This is the related parameter that I am creating in my camel route using the
DSL:
{code:java}
parameters.add(new RestOperationParamDefinition()
.name("identification")
.type(RestParamType.query)
.required(true)
.description("The types of identification to include")
.allowableValues(IdentificationType.getAllTypes())
.collectionFormat(CollectionFormat.csv)
.dataType("array")
.arrayType("string"));
{code}
If it helps, here is the entirety of the route:
{code:java}
public class ClassifierRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
rest("/classifier")
.description("MatchX Classifier REST API")
.id("Classifier route")
.get()
.description("Gets classifiers based on
supplied parameters")
.produces(MediaType.APPLICATION_JSON)
.outType(Identification.class)
.responseMessage()
.code(200)
.message("Returns a result set in JSON
format")
.endResponseMessage()
.responseMessage()
.code(400)
.message("The supplied query is
invalid")
.endResponseMessage()
.params(addParameters())
.to("direct:algorithmMatch");
from("direct:algorithmMatch")
.bean(ClassifierMediator.class,
"getAlgorithmMatchCount")
.marshal()
.json(JsonLibrary.Jackson);
}
private List<RestOperationParamDefinition> addParameters() {
List<RestOperationParamDefinition> parameters =
Lists.newArrayList();
parameters.add(new RestOperationParamDefinition()
.name("feature")
.type(RestParamType.query)
.required(false)
.description("The classifier feature type.")
.allowableValues(FeatureType.getAllTypes()));
parameters.add(new RestOperationParamDefinition()
.name("rating")
.type(RestParamType.query)
.required(true)
.description("The rating of the associated
classifier. Takes everything up to and including this number.")
.allowableValues("0", "1", "2", "3", "4")
.dataType("integer"));
parameters.add(new RestOperationParamDefinition()
.name("identification")
.type(RestParamType.query)
.required(true)
.description("The types of identification to
include")
.allowableValues(IdentificationType.getAllTypes())
.collectionFormat(CollectionFormat.csv)
.dataType("array")
.arrayType("string"));
parameters.add(new RestOperationParamDefinition()
.name("from")
.type(RestParamType.query)
.required(true)
.dataType("string")
.dataFormat("date")
.description("yyyy-MM-dd"));
parameters.add(new RestOperationParamDefinition()
.name("to")
.type(RestParamType.query)
.required(true)
.dataType("string")
.dataFormat("date")
.description("yyyy-MM-dd"));
return parameters;
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)