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

Camel-swagger-java doesn't parse multiple required parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 2.18.0
    • None
    • camel-swagger
    • None
    • Ubuntu 16.04

    • Unknown

    Description

      This issue is related to camel-swagger-java (not camel-swagger)

      Simple Model :

      Platform.java
      @ApiModel(description = "Represents a platform")
      public class Platform {
          String name;
          String owner;
      
          public Platform() {}
      
          @ApiModelProperty(value = "Name of the platform", required = true)
          public String getName() {
              return name;
          }
      
          public void setName(String name) {
              this.name = name;
          }
      
          @ApiModelProperty(value = "Owner of the platform", required = true)
          public String getOwner() {
              return owner;
          }
      
          public void setOwner(String owner) {
              this.owner = owner;
          }
      }
      

      Simple REST Definition :

      RouteBuilder.java
      restConfiguration().component("netty4-http")
      
                  ...
      
              rest("/platform").description("Deploy platform")
                      .consumes("application/json").produces("application/json")
      
                      .post("/deploy").description("Deploy platform").type(Platform.class)
                      .param().name("body").type(body).description("Platform").endParam()
                      .to("bean:platformController?method=deployPlatform");
      

      Swagger.json is containing required parameters :

      swagger.json
      "definitions": {
              "Platform": {
                  "type": "object",
                  "required": [
                      "name",
                      "owner",
      ...
      

      Now let's try a POST request without name value :

      body.json
      {
        "owner":"toto"
      }
      
      return.json
      {
          "status": "failure",
          "message": "Name must be provided."
      }
      

      Here it's working fine, now let's try to remove owner parameter instead of name:

      body.json
      {
        "name":"totopf"
      }
      
      return.json
      {
          "status": "failure",
          "message": "A platform with the same name is already existing"
      }
      

      Now, the request is accepted and my code is receiving a Platform object with null value for owner....

      Expected behavior would be :

      body.json
      {
        "name":"totopf"
      }
      
      return.json
      {
          "status": "failure",
          "message": "Owner must be provided."
      }
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            Sufod Jeremy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: