quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Getters for optional values in cpp should return a const reference

Open flounderpinto opened this issue 9 months ago • 0 comments

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: Screenshot from 2025-01-16 09-53-48 Screenshot from 2025-01-16 09-55-05

flounderpinto avatar Jan 14 '25 21:01 flounderpinto