Skip to content

Getters for optional values in cpp should return a const reference #2675

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

flounderpinto
Copy link

@flounderpinto flounderpinto commented Jan 14, 2025

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Getters for optional values in C++ should return a const reference
1 participant