@@ -54,9 +54,9 @@ private Object[][] expectedSchemaFromTypes() {
5454 public void resolveSchemaFromType (Class <?> aClass , Map <String , Object > expected ) {
5555 Schema schema = AnnotationsUtils .resolveSchemaFromType (aClass , new Components (), null );
5656
57- assertEquals (schema .getType (), expected .get ("type" ));
58- assertEquals (schema .getFormat (), expected .get ("format" ));
59- assertEquals (schema .get$ref (), expected .get ("$ref" ));
57+ assertEquals (schema .getType (), expected .get ("type" ));
58+ assertEquals (schema .getFormat (), expected .get ("format" ));
59+ assertEquals (schema .get$ref (), expected .get ("$ref" ));
6060 }
6161
6262 @ DataProvider
@@ -75,10 +75,10 @@ public void getSchema(String methodName, Map<String, Object> expected) throws No
7575 Content annotationContent = method .getAnnotation (ApiResponse .class ).content ()[0 ];
7676 Optional <? extends Schema > schema = AnnotationsUtils .getSchema (annotationContent , new Components (), null , false );
7777
78- assertTrue (schema .isPresent ());
79- assertEquals (schema .get ().getType (), expected .get ("type" ));
80- assertEquals (schema .get ().getFormat (), expected .get ("format" ));
81- assertEquals (schema .get ().get$ref (), expected .get ("$ref" ));
78+ assertTrue (schema .isPresent ());
79+ assertEquals (schema .get ().getType (), expected .get ("type" ));
80+ assertEquals (schema .get ().getFormat (), expected .get ("format" ));
81+ assertEquals (schema .get ().get$ref (), expected .get ("$ref" ));
8282 }
8383
8484 @ ApiResponse (content = @ Content (schema = @ io .swagger .v3 .oas .annotations .media .Schema (implementation = Byte .class )))
@@ -99,4 +99,31 @@ private void dummyType() {
9999
100100 class DummyClass implements Serializable {}
101101
102+ static class ExampleHolder {
103+ @ io .swagger .v3 .oas .annotations .media .Schema (type = "string" , example = "5 lacs per annum" )
104+ String value ;
105+ }
106+
107+ @ Test
108+ public void testExampleStartingWithNumberShouldBeString () throws Exception {
109+ io .swagger .v3 .oas .annotations .media .Schema schemaAnnotation =
110+ ExampleHolder .class
111+ .getDeclaredField ("value" )
112+ .getAnnotation (io .swagger .v3 .oas .annotations .media .Schema .class );
113+
114+ Optional <Schema > schema =
115+ AnnotationsUtils .getSchemaFromAnnotation (
116+ schemaAnnotation ,
117+ null ,
118+ null ,
119+ false ,
120+ null ,
121+ Schema .SchemaResolution .DEFAULT ,
122+ null
123+ );
124+
125+ assertTrue (schema .isPresent ());
126+ assertEquals (schema .get ().getExample (), "5 lacs per annum" );
127+ }
128+
102129}
0 commit comments