[ 
https://issues.apache.org/jira/browse/CAMEL-21478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17904269#comment-17904269
 ] 

Chamodya Dias commented on CAMEL-21478:
---------------------------------------

Hi [~davsclaus], 



This has been implemented by Calle Andersson 
(https://github.com/calleandersson) here in 4.9 version: 
[https://github.com/apache/camel/blob/a105e6a9f52a14b19795664440fb9fdc6a0fea20/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/OpenApiUtils.java#L264]

I've tested it out, it works when the schema key is provided as the POJO class 
name.

Kindly suggest if it is okay to implement using the schema title as well as 
another condition for 4.10 version.

 

> camel-rest-openapi: Input and output types binding to java classes using $ref 
> or title of the schema
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-21478
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21478
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-rest-openapi
>    Affects Versions: 4.8.0, 4.8.1
>            Reporter: Chamodya Dias
>            Priority: Minor
>             Fix For: 4.10.0
>
>
> Currently, camel resolves the Java class names for RestBindingConfiguration 
> from Schema XML attribute.
> Implemented at: org.apache.camel.component.rest.openapi.RestOpenApiProcessor
> ```
> private RestBindingConfiguration createRestBindingConfiguration(Operation o) 
> throws Exception {
> ...
> ...
> Schema s = m.getValue().getSchema();
> // $ref is null, so we need to know the schema name via XML
> if (s != null && s.getXml() != null) {
> String ref = s.getXml().getName();
> ...
> ```
>  
> But the documentation says Camel can resolve the schema from the schema name: 
> [https://camel.apache.org/manual/rest-dsl-openapi.html#_binding_to_pojo_classes]
>  
> This improvement suggests adding an `else-if` condition that to above code 
> that uses `$ref` to resolve the schema name if available and another 
> `else-if` condition that uses the `title` attribute 
> (https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#schema-object)
>  of the schema to get the class name if available.
>  
> Also, the current implementation doesn't resolve class names when using the 
> `requestBodies` component directly in the OAS. It only uses `content` 
> attribute.
>  
> example:
> ```
> requestBody:
>   $ref: '#/components/requestBodies/createProduct'
> ```
> This improvement suggests the capability to add this also.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to