Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12420

Swagger definition broken when working with dataType array

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.21.0
    • Fix Version/s: 2.22.0
    • Component/s: camel-swagger
    • Labels:
      None
    • Environment:
    • Estimated Complexity:
      Novice

      Description

      I've created two gists.

      This first gist is generated by camel-swagger-java:2.21.0 and is broken
      Copy the contents and paste into the Swagger Editor. 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. The enum type in the broken version, line 76, should be inside the `items` object, according to this issue at swagger-ui.

      This current behavior seems to have been correct some time back.

      This is the related parameter that I am creating in my camel route using the DSL:

      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"));
      

      If it helps, here is the entirety of the route:

      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;
      	}
      
      }
      

        Attachments

          Activity

            People

            • Assignee:
              zregvart Zoran Regvart
              Reporter:
              hochas Johan Karlsson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: