mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
[Avro] Default value for no required fields to null (#7006)
* Default value for the non required fields to null When a field is not required, the avro schema has no default value. Has described in an [avro issues](https://issues.apache.org/jira/browse/AVRO-1803), the property default: null must be set. If we don't do this in the avro file, when we generate java code from generated avro schema, the builder fail if the data isn't set in the avro data class. * Update generated avro sample
This commit is contained in:
parent
2ab35e0386
commit
b1dcf65c5b
@ -3,7 +3,8 @@
|
||||
{
|
||||
"name": "{{baseName}}",
|
||||
"type": {{^required}}["null", {{/required}}{{>typeProperty}}{{^required}}]{{/required}},
|
||||
"doc": "{{{description}}}"
|
||||
"doc": "{{{description}}}"{{^required}},
|
||||
"default": null{{/required}}
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
]
|
||||
]
|
||||
|
@ -0,0 +1,8 @@
|
||||
ApiResponse.avsc
|
||||
Category.avsc
|
||||
InlineObject.avsc
|
||||
InlineObject1.avsc
|
||||
Order.avsc
|
||||
Pet.avsc
|
||||
Tag.avsc
|
||||
User.avsc
|
@ -1 +1 @@
|
||||
4.2.0-SNAPSHOT
|
||||
5.0.0-SNAPSHOT
|
@ -7,17 +7,21 @@
|
||||
{
|
||||
"name": "code",
|
||||
"type": ["null", "int"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,15 @@
|
||||
{
|
||||
"name": "id",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,15 @@
|
||||
{
|
||||
"name": "name",
|
||||
"type": ["null", "string"],
|
||||
"doc": "Updated name of the pet"
|
||||
"doc": "Updated name of the pet",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"type": ["null", "string"],
|
||||
"doc": "Updated status of the pet"
|
||||
"doc": "Updated status of the pet",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,15 @@
|
||||
{
|
||||
"name": "additionalMetadata",
|
||||
"type": ["null", "string"],
|
||||
"doc": "Additional data to pass to server"
|
||||
"doc": "Additional data to pass to server",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "file",
|
||||
"type": ["null", "model.File"],
|
||||
"doc": "file to upload"
|
||||
"doc": "file to upload",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,22 +7,26 @@
|
||||
{
|
||||
"name": "id",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "petId",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "quantity",
|
||||
"type": ["null", "int"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "shipDate",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
@ -35,12 +39,15 @@
|
||||
"delivered"
|
||||
]
|
||||
}],
|
||||
"doc": "Order Status"
|
||||
"doc": "Order Status",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "complete",
|
||||
"type": ["null", "boolean"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,14 @@
|
||||
{
|
||||
"name": "id",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "category",
|
||||
"type": ["null", "model.Category"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
@ -33,7 +35,8 @@
|
||||
"type": "array",
|
||||
"items": "model.Tag"
|
||||
}],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
@ -46,7 +49,9 @@
|
||||
"sold"
|
||||
]
|
||||
}],
|
||||
"doc": "pet status in the store"
|
||||
"doc": "pet status in the store",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,15 @@
|
||||
{
|
||||
"name": "id",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -7,42 +7,51 @@
|
||||
{
|
||||
"name": "id",
|
||||
"type": ["null", "long"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "username",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "firstName",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "lastName",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "phone",
|
||||
"type": ["null", "string"],
|
||||
"doc": ""
|
||||
"doc": "",
|
||||
"default": null
|
||||
},
|
||||
{
|
||||
"name": "userStatus",
|
||||
"type": ["null", "int"],
|
||||
"doc": "User Status"
|
||||
"doc": "User Status",
|
||||
"default": null
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user