Class CleanSchemaDefinitionNamingStrategy
java.lang.Object
com.github.victools.jsonschema.generator.naming.CleanSchemaDefinitionNamingStrategy
- All Implemented Interfaces:
SchemaDefinitionNamingStrategy,StatefulConfig
public class CleanSchemaDefinitionNamingStrategy
extends Object
implements SchemaDefinitionNamingStrategy
Wrapper for a
SchemaDefinitionNamingStrategy that performs a specific clean-up task on all returned values.-
Constructor Summary
ConstructorsConstructorDescriptionCleanSchemaDefinitionNamingStrategy(SchemaDefinitionNamingStrategy strategy, Function<String, String> cleanUpTask) Constructor expecting a naming strategy to be wrapped and the applicable clean-up task. -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustDuplicateNames(Map<DefinitionKey, String> subschemasWithDuplicateNames, SchemaGenerationContext generationContext) Adjust the names/keys in the "definitions"/"$defs" for the given definition references that have the same names (according toSchemaDefinitionNamingStrategy.getDefinitionNameForKey(DefinitionKey, SchemaGenerationContext)) to ensure their uniqueness.adjustNullableName(DefinitionKey key, String definitionName, SchemaGenerationContext generationContext) Provide an alternative definition name for the given key and name when it is nullable.getDefinitionNameForKey(DefinitionKey key, SchemaGenerationContext generationContext) Getter for the name/key in the "definitions"/"$defs" to represent the givenDefinitionKey.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.victools.jsonschema.generator.StatefulConfig
resetAfterSchemaGenerationFinished
-
Constructor Details
-
CleanSchemaDefinitionNamingStrategy
public CleanSchemaDefinitionNamingStrategy(SchemaDefinitionNamingStrategy strategy, Function<String, String> cleanUpTask) Constructor expecting a naming strategy to be wrapped and the applicable clean-up task.- Parameters:
strategy- definition naming strategy to be wrappedcleanUpTask- task discarding/replacing illegal characters
-
-
Method Details
-
getDefinitionNameForKey
Description copied from interface:SchemaDefinitionNamingStrategyGetter for the name/key in the "definitions"/"$defs" to represent the givenDefinitionKey.- Specified by:
getDefinitionNameForKeyin interfaceSchemaDefinitionNamingStrategy- Parameters:
key- definition reference for a type (there may be multiple different keys for the same type if custom definitions are involved)generationContext- generation context providing access to the applied configuration and type context- Returns:
- name/key in "definitions"/"$defs" for the indicated subschema
- See Also:
-
adjustDuplicateNames
public void adjustDuplicateNames(Map<DefinitionKey, String> subschemasWithDuplicateNames, SchemaGenerationContext generationContext) Description copied from interface:SchemaDefinitionNamingStrategyAdjust the names/keys in the "definitions"/"$defs" for the given definition references that have the same names (according toSchemaDefinitionNamingStrategy.getDefinitionNameForKey(DefinitionKey, SchemaGenerationContext)) to ensure their uniqueness.
By default, a numeric counter is appended after a separating dash to each duplicate name.- Specified by:
adjustDuplicateNamesin interfaceSchemaDefinitionNamingStrategy- Parameters:
subschemasWithDuplicateNames- definition references that initially have the same values that should be adjustedgenerationContext- generation context providing access to the applied configuration and type context- See Also:
-
adjustNullableName
public String adjustNullableName(DefinitionKey key, String definitionName, SchemaGenerationContext generationContext) Description copied from interface:SchemaDefinitionNamingStrategyProvide an alternative definition name for the given key and name when it is nullable.
By default, a"-nullable"suffix will be appended.- Specified by:
adjustNullableNamein interfaceSchemaDefinitionNamingStrategy- Parameters:
key- definition reference for a type (there may be multiple different keys for the same type if custom definitions are involved)definitionName- previous result ofSchemaDefinitionNamingStrategy.getDefinitionNameForKey(DefinitionKey, SchemaGenerationContext)to be adjustedgenerationContext- generation context providing access to the applied configuration and type context- Returns:
- adjusted definition name
-