Search code examples
jsonswagger-uiconnexion

anyOf in OAS 3.0 for requestBody that is url encoded form data does not render obvious inputs in swagger UI


connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0

"anyOf" in the open APi specs does not render any useful inputs to the fields/elements in the requestBody. The generated curl request takes wrong key:values

    "components": {
        "requestBodies": {
            "customEventBody": {[enter image description here][1]
                    "content": {
                            "application/x-www-form-urlencoded":{
                                   "schema": {
                                        "anyOf": [
                                             {
                                                "$ref": "#/components/schemas/Interrupt"
                                             },
                                             {
                                                "$ref": "#/components/schemas/injected_val"
                                             },
                                             {
                                                "$ref": "#/components/schemas/document"
                                             }
                                           ]
                                           }
                                    }
                            },
                       }
           },
           "schemas": {
              "Interrupt": {
                 "title": "Interrupt event",
                 "type": "object",
                 "properties": {
                        "Interrupt": {
                                 "type": "boolean"
                             }
                     }
               },
              "injected_val": {
                 "title": "Injected value",
                 "type": "object",
                 "properties": {
                        "injected_val": {
                                 "type": "string"
                             }
                     }
               },
              "document": {
                 "title": "document",
                 "type": "object",
                 "properties": {
                        "document": {
                                 "type": "string"
                             }
                     }
               }
            }
     }
}

generated Curl request when I want to try out the curl command from swagger UI:

curl -X POST "http://xx.yy.zz.ee:8080/api/v1/calls/54544/js" -H "accept: /" -H "Content-Type: application/x-www-form-urlencoded" -d "0='&1=I&2=n&3=t&4=e&5=r&6=r&7=u&8=p&9=t&10='&11=%3D&12='&13=t&14=r&15=u&16=e&17='"

Swagger UI example screenshot:


Solution

  • Currently (as of v. 3.23.5) Swagger UI does not support form data with oneOf and anyOf. You can open an issue in the Swagger UI issue repository:

    https://github.com/swagger-api/swagger-ui/issues