Chamodya Dias created CAMEL-21478:
-------------------------------------

             Summary: 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.1, 4.8.0
            Reporter: Chamodya Dias


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 uses `$ref` to 
resolve the schema name if available or another `else-if` condition that uses 
the `title` attribute 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