public class SchemaHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SchemaHelper() |
| Modifier and Type | Method and Description |
|---|---|
static com.sun.codemodel.JCodeModel |
buildBodyJCodeModel(String basePackage,
String schemaLocation,
String name,
String schema,
org.jsonschema2pojo.GenerationConfig config,
org.jsonschema2pojo.Annotator annotator)
Builds a JCodeModel for classes that will be used as Request or Response bodies
|
static boolean |
containsBodySchema(Map<String,RamlMimeType> body,
RamlRoot document,
boolean checkForValidSchema)
Checks if a Map of mime types contains at least 1 valid JsonSchema.
|
static String |
convertClassToJsonSchema(ApiParameterMetadata clazz,
String responseDescription,
JavaDocStore javaDocStore)
Uses Jackson object mappers to convert an ajaxcommandparameter annotated type into its
JSONSchema representation.
|
static String |
convertClassToJsonSchema(Type clazz,
String responseDescription,
JavaDocStore javaDocStore)
Uses Jackson object mappers to convert a Pojo into its JSONSchema representation.
|
static Map<String,RamlQueryParameter> |
convertClassToQueryParameters(Parameter param,
JavaDocStore javaDocStore)
Breaks down a class into component fields which are mapped as Query Parameters.
|
static Map<String,RamlQueryParameter> |
convertParameterToQueryParameter(Parameter param,
String paramComment)
Converts a simple parameter, ie String, or Boxed Primitive into
|
static String |
extractNameFromSchema(String schema,
String schemaName,
String fallbackName)
Extracts the name from a schema in this order of precedence:
1.
|
static org.jsonschema2pojo.GenerationConfig |
getDefaultGenerationConfig()
Returns a configuration for the JSON Schema 2 POJO that is in line with the defaults used in
the plugin so far
|
static org.jsonschema2pojo.GenerationConfig |
getGenerationConfig(Boolean generateBuilders,
Boolean includeAdditionalProperties,
Boolean includeDynamicAccessors,
Boolean useLongIntegers)
Returns a generation config with the supplied parameters.
|
static ApiBodyMetadata |
mapSchemaToPojo(RamlRoot document,
String schema,
String basePackage,
String name,
String schemaLocation)
Maps a JSON Schema to a JCodeModel using JSONSchema2Pojo and encapsulates it along with some
metadata into an
ApiBodyMetadata object. |
static RamlParamType |
mapSimpleType(Class<?> clazz)
Maps primitives and other simple Java types into simple types supported by RAML
|
static Class<?> |
mapSimpleType(RamlParamType param)
Maps simple types supported by RAML into primitives and other simple Java types
|
static String |
resolveSchema(String schema,
RamlRoot document)
Utility method that will return a schema if the identifier is valid and exists in the raml
file definition.
|
public static Map<String,RamlQueryParameter> convertParameterToQueryParameter(Parameter param, String paramComment)
param - The Java Parameter to convertparamComment - The associated Javadoc if anypublic static String resolveSchema(String schema, RamlRoot document)
schema - The name of the schema to resolvedocument - The Parent Raml Documentpublic static Map<String,RamlQueryParameter> convertClassToQueryParameters(Parameter param, JavaDocStore javaDocStore)
param - The Parameter representing the class to be converted into query parametersjavaDocStore - The associated JavaDoc (if any)public static String convertClassToJsonSchema(ApiParameterMetadata clazz, String responseDescription, JavaDocStore javaDocStore)
clazz - The Class to convertresponseDescription - The javadoc description supplied if availablejavaDocStore - The Entire java doc store availablepublic static String convertClassToJsonSchema(Type clazz, String responseDescription, JavaDocStore javaDocStore)
clazz - The Class to be inspectedresponseDescription - The description to be embedded in the responsejavaDocStore - Associated JavaDoc for this class that can be embedded in the schemapublic static RamlParamType mapSimpleType(Class<?> clazz)
clazz - The Class to mappublic static Class<?> mapSimpleType(RamlParamType param)
param - The Type to mappublic static String extractNameFromSchema(String schema, String schemaName, String fallbackName)
schema - The Actual JSON SchemaschemaName - The name of the schema within the documentfallbackName - any arbitrary namepublic static ApiBodyMetadata mapSchemaToPojo(RamlRoot document, String schema, String basePackage, String name, String schemaLocation)
ApiBodyMetadata object.document - The Raml document being parsedschema - The Schema (full schema or schema name to be resolved)basePackage - The base package for the classes we are generatingname - The suggested name of the class based on the api call and whether it's a
request/response. This will only be used if no suitable alternative is found in
the schemaschemaLocation - Base location of this schema, will be used to create absolute URIs for $ref tags
eg "classpath:/"public static com.sun.codemodel.JCodeModel buildBodyJCodeModel(String basePackage, String schemaLocation, String name, String schema, org.jsonschema2pojo.GenerationConfig config, org.jsonschema2pojo.Annotator annotator)
basePackage - The package we will be using for the domain objectsschemaLocation - The location of this schema, will be used to create absolute URIs for $ref tags eg
"classpath:/"name - The class nameschema - The JSON Schema representing this classconfig - JsonSchema2Pojo configuration. if null a default config will be usedannotator - JsonSchema2Pojo annotator. if null a default annotator will be usedpublic static org.jsonschema2pojo.GenerationConfig getDefaultGenerationConfig()
public static org.jsonschema2pojo.GenerationConfig getGenerationConfig(Boolean generateBuilders, Boolean includeAdditionalProperties, Boolean includeDynamicAccessors, Boolean useLongIntegers)
generateBuilders - Enables or disables GenerationConfig.isGenerateBuilders()includeAdditionalProperties - Enables or disables GenerationConfig.isIncludeAdditionalProperties()includeDynamicAccessors - Enables or disables GenerationConfig.isIncludeDynamicAccessors()useLongIntegers - Enables or disables GenerationConfig.isUseLongIntegers()public static boolean containsBodySchema(Map<String,RamlMimeType> body, RamlRoot document, boolean checkForValidSchema)
body - The request/response bodydocument - the RAML document being checkedcheckForValidSchema - if false, we will omit checks to see if the schema is validCopyright © 2017. All rights reserved.