File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
src/main/java/io/asfjava/ui/core Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ public class NumberGenerator implements FormDefinitionGenerator {
1212 public void generate (ObjectNode fieldFormDefinition , Field field ) {
1313 Number annotation = field .getAnnotation (Number .class );
1414 fieldFormDefinition .put ("key" , field .getName ());
15- fieldFormDefinition .put ("title" , annotation .title ());
1615 fieldFormDefinition .put ("type" , "number" );
1716
17+ String title = annotation .title ();
18+ if (!title .isEmpty ()) {
19+ fieldFormDefinition .put ("title" , title );
20+ }
21+
1822 String description = annotation .description ();
1923 if (!description .isEmpty ()) {
2024 fieldFormDefinition .put ("description" , description );
Original file line number Diff line number Diff line change 1+ package io .asfjava .ui .core .schema .decorators ;
2+
3+ import com .fasterxml .jackson .databind .BeanProperty ;
4+ import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
5+ import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
6+
7+ import io .asfjava .ui .core .form .Number ;
8+
9+ public class NumberSchemaDecorator implements SchemaDecorator {
10+
11+ @ Override
12+ public void customizeSchema (BeanProperty property , JsonSchema jsonschema ) {
13+ Number annotation = property .getAnnotation (Number .class );
14+ if (annotation != null && annotation .title () != null ) {
15+ ((StringSchema ) jsonschema ).setTitle (annotation .title ());
16+ }
17+ }
18+
19+ @ Override
20+ public String getAnnotation () {
21+ return Number .class .getName ();
22+ }
23+
24+ }
You can’t perform that action at this time.
0 commit comments