use of com.github.victools.jsonschema.generator.SchemaGeneratorGeneralConfigPart in project jsonschema-generator by victools.
the class JacksonModule method applyToConfigBuilder.
@Override
public void applyToConfigBuilder(SchemaGeneratorConfigBuilder builder) {
this.objectMapper = builder.getObjectMapper();
SchemaGeneratorConfigPart<FieldScope> fieldConfigPart = builder.forFields();
SchemaGeneratorConfigPart<MethodScope> methodConfigPart = builder.forMethods();
this.applyToConfigBuilderPart(fieldConfigPart);
this.applyToConfigBuilderPart(methodConfigPart);
fieldConfigPart.withIgnoreCheck(this::shouldIgnoreField);
methodConfigPart.withIgnoreCheck(this::shouldIgnoreMethod);
if (!this.options.contains(JacksonOption.IGNORE_PROPERTY_NAMING_STRATEGY)) {
// only consider @JsonNaming as fall-back
fieldConfigPart.withPropertyNameOverrideResolver(this::getPropertyNameOverrideBasedOnJsonNamingAnnotation);
}
SchemaGeneratorGeneralConfigPart generalConfigPart = builder.forTypesInGeneral();
generalConfigPart.withDescriptionResolver(this::resolveDescriptionForType);
boolean considerEnumJsonValue = this.options.contains(JacksonOption.FLATTENED_ENUMS_FROM_JSONVALUE);
boolean considerEnumJsonProperty = this.options.contains(JacksonOption.FLATTENED_ENUMS_FROM_JSONPROPERTY);
if (considerEnumJsonValue || considerEnumJsonProperty) {
generalConfigPart.withCustomDefinitionProvider(new CustomEnumDefinitionProvider(considerEnumJsonValue, considerEnumJsonProperty));
}
if (this.options.contains(JacksonOption.RESPECT_JSONPROPERTY_ORDER)) {
generalConfigPart.withPropertySorter(new JsonPropertySorter(true));
}
boolean lookUpSubtypes = !this.options.contains(JacksonOption.SKIP_SUBTYPE_LOOKUP);
boolean includeTypeInfoTransform = !this.options.contains(JacksonOption.IGNORE_TYPE_INFO_TRANSFORM);
if (lookUpSubtypes || includeTypeInfoTransform) {
JsonSubTypesResolver subtypeResolver = new JsonSubTypesResolver();
if (lookUpSubtypes) {
generalConfigPart.withSubtypeResolver(subtypeResolver);
fieldConfigPart.withTargetTypeOverridesResolver(subtypeResolver::findTargetTypeOverrides);
methodConfigPart.withTargetTypeOverridesResolver(subtypeResolver::findTargetTypeOverrides);
}
if (includeTypeInfoTransform) {
generalConfigPart.withCustomDefinitionProvider(subtypeResolver);
fieldConfigPart.withCustomDefinitionProvider(subtypeResolver::provideCustomPropertySchemaDefinition);
methodConfigPart.withCustomDefinitionProvider(subtypeResolver::provideCustomPropertySchemaDefinition);
}
}
}
Aggregations