quicktype
quicktype copied to clipboard
Getters for optional values in cpp should return a const reference
Overview Fixes #2674. I can't entirely confirm that it doesn't have some unintended side effects, but this does fix the return type of optional values.
Test file:
{ "$schema": "http://json-schema.org/draft-06/schema#", "$ref": "#/definitions/foo", "definitions": { "coordinate": { "type": "object", "required": [ "latitude", "longitude" ], "additionalProperties": false, "properties": { "latitude": { "type": "integer", "minimum": 0, "maximum": 999999 }, "longitude": { "type": "number", "minimum": 0, "maximum": 999999 }, "baz": { "type": "string", "minLength": 0, "maxLength": 999, "pattern": "*" } } }, "coordinates": { "type": "array", "items": { "$ref": "#/definitions/coordinate" } }, "foo": { "type": "object", "required": [ ], "additionalProperties": false, "properties": { "coordinates": { "$ref": "#/definitions/coordinates" }, "bar" : { "type": "number" } } } } }
Diff of generated file changes: