forked from loafle/openapi-generator-original
[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}}",
|
"name": "{{baseName}}",
|
||||||
"type": {{^required}}["null", {{/required}}{{>typeProperty}}{{^required}}]{{/required}},
|
"type": {{^required}}["null", {{/required}}{{>typeProperty}}{{^required}}]{{/required}},
|
||||||
"doc": "{{{description}}}"
|
"doc": "{{{description}}}"{{^required}},
|
||||||
|
"default": null{{/required}}
|
||||||
}{{^-last}},{{/-last}}
|
}{{^-last}},{{/-last}}
|
||||||
{{/vars}}
|
{{/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",
|
"name": "code",
|
||||||
"type": ["null", "int"],
|
"type": ["null", "int"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "message",
|
"name": "message",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,15 @@
|
|||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,15 @@
|
|||||||
{
|
{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": "Updated name of the pet"
|
"doc": "Updated name of the pet",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": "Updated status of the pet"
|
"doc": "Updated status of the pet",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,15 @@
|
|||||||
{
|
{
|
||||||
"name": "additionalMetadata",
|
"name": "additionalMetadata",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": "Additional data to pass to server"
|
"doc": "Additional data to pass to server",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"type": ["null", "model.File"],
|
"type": ["null", "model.File"],
|
||||||
"doc": "file to upload"
|
"doc": "file to upload",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,22 +7,26 @@
|
|||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "petId",
|
"name": "petId",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "quantity",
|
"name": "quantity",
|
||||||
"type": ["null", "int"],
|
"type": ["null", "int"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shipDate",
|
"name": "shipDate",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
@ -35,12 +39,15 @@
|
|||||||
"delivered"
|
"delivered"
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
"doc": "Order Status"
|
"doc": "Order Status",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "complete",
|
"name": "complete",
|
||||||
"type": ["null", "boolean"],
|
"type": ["null", "boolean"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,14 @@
|
|||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "category",
|
"name": "category",
|
||||||
"type": ["null", "model.Category"],
|
"type": ["null", "model.Category"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
@ -33,7 +35,8 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": "model.Tag"
|
"items": "model.Tag"
|
||||||
}],
|
}],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "status",
|
"name": "status",
|
||||||
@ -46,7 +49,9 @@
|
|||||||
"sold"
|
"sold"
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
"doc": "pet status in the store"
|
"doc": "pet status in the store",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,15 @@
|
|||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,42 +7,51 @@
|
|||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": ["null", "long"],
|
"type": ["null", "long"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "username",
|
"name": "username",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "firstName",
|
"name": "firstName",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lastName",
|
"name": "lastName",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "email",
|
"name": "email",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "password",
|
"name": "password",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phone",
|
"name": "phone",
|
||||||
"type": ["null", "string"],
|
"type": ["null", "string"],
|
||||||
"doc": ""
|
"doc": "",
|
||||||
|
"default": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "userStatus",
|
"name": "userStatus",
|
||||||
"type": ["null", "int"],
|
"type": ["null", "int"],
|
||||||
"doc": "User Status"
|
"doc": "User Status",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user