File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
models/spring-ai-google-genai/src/test/java/org/springframework/ai/google/genai/schema Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,51 @@ void fromJsonShouldHandleNullInput() {
7474 assertThatThrownBy (() -> JsonSchemaConverter .fromJson (null )).isInstanceOf (RuntimeException .class );
7575 }
7676
77+ @ Test
78+ void shouldHandleBooleanAdditionalProperties () {
79+ String json = """
80+ {
81+ "type": "object",
82+ "additionalProperties": true
83+ }
84+ """ ;
85+ ObjectNode result = JsonSchemaConverter .convertToOpenApiSchema (JsonSchemaConverter .fromJson (json ));
86+ assertThat (result .get ("additionalProperties" ).asBoolean ()).isTrue ();
87+ }
88+
89+ @ Test
90+ void shouldHandleEnumProperty () {
91+ String json = """
92+ {
93+ "type": "string",
94+ "enum": ["a", "b", "c"]
95+ }
96+ """ ;
97+ ObjectNode result = JsonSchemaConverter .convertToOpenApiSchema (JsonSchemaConverter .fromJson (json ));
98+ assertThat (result .get ("enum" )).isNotNull ();
99+ assertThat (result .get ("enum" ).get (0 ).asText ()).isEqualTo ("a" );
100+ assertThat (result .get ("enum" ).get (1 ).asText ()).isEqualTo ("b" );
101+ assertThat (result .get ("enum" ).get (2 ).asText ()).isEqualTo ("c" );
102+ }
103+
104+ @ Test
105+ void shouldHandleOpenApiSpecificProperties () {
106+ String json = """
107+ {
108+ "type": "string",
109+ "nullable": true,
110+ "readOnly": true,
111+ "writeOnly": false,
112+ "description": {"propertyName": "type"}
113+ }
114+ """ ;
115+ ObjectNode result = JsonSchemaConverter .convertToOpenApiSchema (JsonSchemaConverter .fromJson (json ));
116+ assertThat (result .get ("nullable" ).asBoolean ()).isTrue ();
117+ assertThat (result .get ("readOnly" ).asBoolean ()).isTrue ();
118+ assertThat (result .get ("writeOnly" ).asBoolean ()).isFalse ();
119+ assertThat (result .get ("description" ).get ("propertyName" ).asText ()).isEqualTo ("type" );
120+ }
121+
77122 @ Nested
78123 class SchemaConversionTests {
79124
You can’t perform that action at this time.
0 commit comments