java.lang.Object
dev.hilla.parser.core.Parser
The entrypoint class. It searches for the endpoint classes in the classpath
and produces an OpenAPI definition.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn immutable parser configuration object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a parserPlugin.adjustOpenAPI(Consumer<io.swagger.v3.oas.models.OpenAPI> action) Allows to programmatically change the default OpenAPI definition.classLoader(ClassLoader classLoader) Allows to change the class loader that the parser uses for reflection.Specifies the classpath where the parser will scan for endpoints.Specifies the classpath where the parser will scan for endpoints.classPath(Collection<String> classPathElements) Specifies the classpath where the parser will scan for endpoints.classPath(Collection<String> classPathElements, boolean override) Specifies the classpath where the parser will scan for endpoints.endpointAnnotation(String annotationFullyQualifiedName) Specifies the name of the endpoint annotation by which the parser will search for the endpoints.endpointAnnotation(String annotationFullyQualifiedName, boolean override) Specifies the name of the endpoint annotation by which the parser will search for the endpoints.endpointExposedAnnotation(String annotationFullyQualifiedName) Specifies the name of the `EndpointExposed` annotation by which the parser will detect if the endpoint superclass should be considered as the part of the endpoint.endpointExposedAnnotation(String annotationFullyQualifiedName, boolean override) Specifies the name of the `EndpointExposed` annotation by which the parser will detect if the endpoint superclass should be considered as the part of the endpoint.io.swagger.v3.oas.models.OpenAPIexecute()Scans the classpath, blocking until the scan is complete.exposedPackages(Collection<String> exposedPackages) exposedPackages(Collection<String> exposedPackages, boolean override) Gets the internal configuration object.openAPISource(String source, OpenAPIFileType type) Parses the OpenAPI source string with the provided parser and merges the result into the current OpenAPI object.Adds a collection of parserPlugins.plugins(Collection<? extends Plugin> plugins) Adds a collection of parserPlugins.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
addPlugin
Adds a parserPlugin.Note that the order of the method calls will be maintained during processing.
- Parameters:
plugin- An instance of the parser plugin.- Returns:
- this (for method chaining).
-
adjustOpenAPI
Allows to programmatically change the default OpenAPI definition.- Parameters:
action- a consumer lambda that accepts an OpenAPI instance.- Returns:
- this (for method chaining).
-
classLoader
Allows to change the class loader that the parser uses for reflection.- Parameters:
classLoader- a class loader instance.- Returns:
- this (for method chaining).
-
classPath
Specifies the classpath where the parser will scan for endpoints. Specifying the classpath is required.If the classpath is already set, it will be overridden.
- Parameters:
classPathElements- a list of paths forming the classpath.- Returns:
- this (for method chaining).
-
classPath
Specifies the classpath where the parser will scan for endpoints. Specifying the classpath is required.- Parameters:
classPathElements- a list of paths forming the classpath.override- specifies if the parser should override the classpath if it is already specified.- Returns:
- this (for method chaining).
-
classPath
Specifies the classpath where the parser will scan for endpoints. Specifying the classpath is required.If the classpath is already set, it will be overridden.
- Parameters:
classPathElements- a list of paths forming the classpath.- Returns:
- this (for method chaining).
-
classPath
Specifies the classpath where the parser will scan for endpoints. Specifying the classpath is required.- Parameters:
classPathElements- a list of paths forming the classpath.override- specifies if the parser should override the classpath if it is already specified.- Returns:
- this (for method chaining).
-
endpointAnnotation
Specifies the name of the endpoint annotation by which the parser will search for the endpoints. Only classes with this annotation will be chosen.If the annotation name is already set, it will be overridden.
- Parameters:
annotationFullyQualifiedName- The fully qualified name of the annotation- Returns:
- this (for method chaining).
-
endpointAnnotation
@Nonnull public Parser endpointAnnotation(@Nonnull String annotationFullyQualifiedName, boolean override) Specifies the name of the endpoint annotation by which the parser will search for the endpoints. Only classes with this annotation will be chosen.- Parameters:
annotationFullyQualifiedName- The fully qualified name of the annotationoverride- specifies if the parser should override the annotation name if it is already specified.- Returns:
- this (for method chaining).
-
endpointExposedAnnotation
Specifies the name of the `EndpointExposed` annotation by which the parser will detect if the endpoint superclass should be considered as the part of the endpoint. Any superclass in the endpoint's inheritance chain will be skipped if it doesn't have this annotation.If the annotation name is already set, it will be overridden.
- Parameters:
annotationFullyQualifiedName- The fully qualified name of the annotation- Returns:
- this (for method chaining).
-
endpointExposedAnnotation
@Nonnull public Parser endpointExposedAnnotation(@Nonnull String annotationFullyQualifiedName, boolean override) Specifies the name of the `EndpointExposed` annotation by which the parser will detect if the endpoint superclass should be considered as the part of the endpoint. Any superclass in the endpoint's inheritance chain will be skipped if it doesn't have this annotation.- Parameters:
annotationFullyQualifiedName- The fully qualified name of the annotationoverride- specifies if the parser should override the annotation name if it is already specified.- Returns:
- this (for method chaining).
-
exposedPackages
-
exposedPackages
@Nonnull public Parser exposedPackages(@Nonnull Collection<String> exposedPackages, boolean override) -
execute
@Nonnull public io.swagger.v3.oas.models.OpenAPI execute()Scans the classpath, blocking until the scan is complete.- Returns:
- A result OpenAPI object.
-
getConfig
Gets the internal configuration object.- Returns:
- configuration object.
-
openAPISource
Parses the OpenAPI source string with the provided parser and merges the result into the current OpenAPI object. This method is useful if you want to adjust some basic parts of the OpenAPI object like the application title, version, server description or URL.If the method is used once, all the changes will be applied to the default OpenAPI object. Called multiple time, this function applies changes one by one in the order of method calls.
- Parameters:
source- The OpenAPI definition in the JSON or YAML format. You don't have to specify all the fields required by the schema; the result definition will use default fields.type- The parser for the OpenAPI definition- Returns:
- this (for method chaining).
-
plugins
Adds a collection of parserPlugins. If there are plugins already specified, they will be removed before addition.Note that the order of the arguments will be maintained during processing.
- Parameters:
plugins- a collection of parser plugins.- Returns:
- this (for method chaining).
-
plugins
Adds a collection of parserPlugins. If there are already specified plugins, they will be removed before addition.Note that the order of collection will be maintained during processing.
- Parameters:
plugins- a collection of parser plugins.- Returns:
- this (for method chaining).
-