From 5cfe4942321eaa6f71a556b80d5b19a236b69bed Mon Sep 17 00:00:00 2001 From: Marko Ristin Date: Sat, 20 Jul 2024 10:11:45 +0200 Subject: [PATCH] Fix error message in Go de-jsonization of strings We erroneously copy-pasted the error message from the function for de-serialization of booleans to the function for de-serialization of strings, misleading the user of the generated code. This patch fixes the issue. --- aas_core_codegen/golang/jsonization/_generate.py | 4 ++-- .../expected_output/jsonization/jsonization.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aas_core_codegen/golang/jsonization/_generate.py b/aas_core_codegen/golang/jsonization/_generate.py index 28811845..ec0802d5 100644 --- a/aas_core_codegen/golang/jsonization/_generate.py +++ b/aas_core_codegen/golang/jsonization/_generate.py @@ -180,7 +180,7 @@ def _generate_string_from_jsonable() -> Stripped: {II}return {I}}} else {{ {II}err = newDeserializationError( -{III}fmt.Sprintf("Expected a boolean, but got %T", jsonable), +{III}fmt.Sprintf("Expected a string, but got %T", jsonable), {II}) {II}return {I}}} @@ -1416,7 +1416,7 @@ def _generate_to_jsonable(symbol_table: intermediate.SymbolTable) -> Stripped: return Stripped( f"""\ -// Serialize ``that`` instance to a JSON-able representation. +// Serialize “that“ instance to a JSON-able representation. // // Return a structure which can be readily converted to JSON, // or an error if some value could not be converted. diff --git a/test_data/golang/test_main/aas_core_meta.v3/expected_output/jsonization/jsonization.go b/test_data/golang/test_main/aas_core_meta.v3/expected_output/jsonization/jsonization.go index 7677c078..41a20f1f 100644 --- a/test_data/golang/test_main/aas_core_meta.v3/expected_output/jsonization/jsonization.go +++ b/test_data/golang/test_main/aas_core_meta.v3/expected_output/jsonization/jsonization.go @@ -178,7 +178,7 @@ func stringFromJsonable( return } else { err = newDeserializationError( - fmt.Sprintf("Expected a boolean, but got %T", jsonable), + fmt.Sprintf("Expected a string, but got %T", jsonable), ) return } @@ -20859,7 +20859,7 @@ func dataSpecificationIEC61360ToMap( return } -// Serialize ``that`` instance to a JSON-able representation. +// Serialize “that“ instance to a JSON-able representation. // // Return a structure which can be readily converted to JSON, // or an error if some value could not be converted.