How to display default value in JSON Schema using Jackson

北战南征 提交于 2021-01-29 06:26:18

问题


I am using Jackson to create json schema. I want to display property with their default value in json schema. I tried @JsonProperty annotation with default attribute but still default value is not being display on the json schema.

I am using following code to generate Json Schema:

    ObjectMapper mapper = new ObjectMapper();
            JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
            JsonSchema schema = null;
            try {
                 schema = schemaGen.generateSchema(RootTemplate.class);
                 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
            } 
            catch (JsonProcessingException e) {
                // TODO Auto-generated catch block

                 e.printStackTrace();
        }

来源:https://stackoverflow.com/questions/61124672/how-to-display-default-value-in-json-schema-using-jackson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!