Hey,

Just a quick update: Here's a minimal gist which shows the issue:

camel run https://gist.github.com/mikoskinen/dccfffd7b6fa6d95f5a0bce66e491765

Hope this helps.

Best regards,
Mikael

to 29. jouluk. 2022 klo 11.08 Mikael Koskinen (mijap...@gmail.com) kirjoitti:
>
> Hi,
>
> I'm testing the Camel JBang 3.20 OpenAPI to REST generator and
> encountering some issues with enums when trying to run the generated
> file. The schema in the error message looks peculiar when trying to
> run the XML DSL as it points to spring but I'm not sure if it should
> look like that.
>
> Error with XML Rest DSL:
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.xml.io.XmlPullParserException: Unexpected element
> '{http://camel.apache.org/schema/spring}allowableValues'
>
> Error with YAML Rest DSL:
> Unsupported field: allowableValues
>  in file:myroutes.yaml, line 124, column 11:
>               value:
>
> More information follows:
>
> I'm using the PetStore OpenAPI 3 spec:
> https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
>
> I'm generating the REST DSL using:
>
> camel generate rest -i openapi.yaml -o myroutes.yaml
>
> The generation goes through without errors. But Camel isn't able to
> parse the generated file when trying to run the routes using camel run
> myroutes.yaml:
>
> ---
> Unsupported field: allowableValues
>  in file:myroutes.yaml, line 124, column 11:
>               value:
>               ^
>
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerBase.handleUnknownProperty(YamlDeserializerBase.java:132)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerBase.setProperties(YamlDeserializerBase.java:126)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerBase.construct(YamlDeserializerBase.java:65)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializationContext$1.construct(YamlDeserializationContext.java:171)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.asType(YamlDeserializerSupport.java:344)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.asCollection(YamlDeserializerSupport.java:322)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.asFlatCollection(YamlDeserializerSupport.java:298)
>     at 
> org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.asFlatList(YamlDeserializerSupport.java:277)
>     at 
> org.apache.camel.dsl.yaml.deserializers.ModelDeserializers$GetDefinitionDeserializer.setProperty(ModelDeserializers.java:5563)
> ---
>
> The generated file contains this which based on the error is failing:
>
>     get:
>     - id: "findPetsByStatus"
>       path: "/pet/findByStatus"
>       description: "Multiple status values can be provided with comma
> separated strings"
>       produces: "application/xml,application/json"
>       param:
>       - dataType: "string"
>         defaultValue: "available"
>         description: "Status values that need to be considered for filter"
>         name: "status"
>         required: false
>         type: "query"
>         allowableValues:
>           value:
>           - "available"
>           - "pending"
>           - "sold"
>       to: "direct:findPetsByStatus"
>
> The original OpenAPI spec has this:
>
>   /pet/findByStatus:
>     get:
>       tags:
>         - pet
>       summary: Finds Pets by status
>       description: Multiple status values can be provided with comma
> separated strings
>       operationId: findPetsByStatus
>       parameters:
>         - name: status
>           in: query
>           description: Status values that need to be considered for filter
>           required: false
>           explode: true
>           schema:
>             type: string
>             enum:
>               - available
>               - pending
>               - sold
>             default: available
>
> I also tried generating XML DSL and it gives the following error when running:
>
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.xml.io.XmlPullParserException: Unexpected element
> '{http://camel.apache.org/schema/spring}allowableValues'
>
> I tried to find the relevant parts from the Apache Camel's source code
> and AFAIK it tries to handle allowableValues. The schema in the XML
> error looks strange though with a reference to spring. Should that be
> rest instead?
>
> Everything works OK with a simpler schema
> (https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml)
>
> Is this a known issue or is there some setting I could change to make
> things work? Thanks in advance!
>
> Best regards,
> Mikael

Reply via email to