Dhairya-007 opened a new pull request, #29971:
URL: https://github.com/apache/camel/pull/29971
## Problem
```java
@XmlAttribute
@Metadata(defaultValue = "avroJackson", description = "Which Avro library to
use.")
private AvroLibrary library = AvroLibrary.Jackson;
```
`avroJackson` is the `dataFormatName` that `AvroLibrary.Jackson` carries,
not the constant:
```java
public enum AvroLibrary {
ApacheAvro("avro"),
Jackson("avroJackson");
```
and the constant is what the attribute takes. So the generated metadata
contradicts itself - the only option in the whole catalog where the declared
default is not one of the declared values:
```json
"library": { "index": 2, ..., "type": "enum", "javaType":
"org.apache.camel.model.dataformat.AvroLibrary",
"enum": [ "ApacheAvro", "Jackson" ], ..., "defaultValue":
"avroJackson",
"description": "Which Avro library to use." }
```
In the YAML DSL schema that lands in a JSON Schema whose `default` is not
among its own `enum`:
```json
"library": {"type": "string", "title": "Library", "description": "Which Avro
library to use.",
"default": "avroJackson", "enum": ["ApacheAvro", "Jackson"]}
```
so an editor validating `camelYamlDsl.json` rejects the default the schema
itself supplies. `camel-spring.xsd` and `camel-xml-io.xsd` both document "Which
Avro library to use. Default value: avroJackson" for an attribute that only
accepts `ApacheAvro` or `Jackson`, and a user who copies that into
`library="avroJackson"` gets a JAXB binding failure.
`JsonDataFormat`, the closest sibling, has it right:
```java
@Metadata(defaultValue = "Jackson", description = "Which json library to
use.")
private JsonLibrary library = JsonLibrary.Jackson;
```
with `"defaultValue": "Jackson"` against `"enum":
["Fastjson","Gson","Jackson","Jsonb"]`.
## Fix
Declare `Jackson`, the constant the field is initialised to. The default
behaviour is unchanged - the field initialiser was always
`AvroLibrary.Jackson`; only the documented name of it was wrong.
The regenerated `avro.json`, the two XSDs and the YAML DSL schemas are
included.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]