Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-4268

Swagger/OAS file from jBPM is not Valid/Conformant

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.4.0.Final
    • None
    • Core Engine
    • None
    • False
    • False
    • Undefined
    • ---
    • ---
    • 2021 Week 07-09 (from Feb 15)

      I am using as a base example integration-tests-springboot-it in here: https://github.com/kiegroup/kogito-runtimes/tree/master/integration-tests/integration-tests-springboot

      The IT project produces the swagger open api spec as attached: openapi (5).json

      Let's focus on a specific part of the Swagger/OAS definition:

                     {
                        "name":"group",
                        "in":"query",
                        "required":false,
                        "schema":{
                           "type":"array",
                           "items":{
                              "type":"string"
                           },
                           "default":""
                        }
                     }
      

      this is available under

      "/subprocess/{id}/review/{workItemId}"

      but equivalently for other endpoints.

      Allegedly this is not valid per Swagger/OAS specification.
      Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#properties

      default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if type is string, then default can be "foo" but cannot be 1.

      So parameter named "group" is defined as an array of string, but the default is empty.

      Using the Swagger Validator (online and offline) confirms this OAS is not Conformant/Valid.

      This appears to be induced by the following codegenerated code and annotation:

      @RequestParam(value = "group", required = false, defaultValue = "") final List<String> groups
      

      Maybe the solution is to avoid specifying an empty string for the defaultValue or supplying an empty array, such as

      "[]"

      ?

            cnicolai@redhat.com Cristiano Nicolai
            mmortari@redhat.com Matteo Mortari
            Marian Macik Marian Macik
            Marian Macik Marian Macik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: