Class AbstractJsonEndpointSpec
java.lang.Object
com.kingsrook.qqq.middleware.javalin.specs.AbstractEndpointSpec<AbstractJsonEndpointSpec.JsonInput,AbstractJsonEndpointSpec.JsonOutput,AbstractJsonEndpointSpec.JsonExecutor>
com.kingsrook.qqq.middleware.javalin.specs.extensions.AbstractJsonEndpointSpec
- Direct Known Subclasses:
HealthSpecSupport,TableApiDocumentSpecV1,TableApisSpecV1,TableFormAdjusterSpecV1
public abstract class AbstractJsonEndpointSpec
extends AbstractEndpointSpec<AbstractJsonEndpointSpec.JsonInput,AbstractJsonEndpointSpec.JsonOutput,AbstractJsonEndpointSpec.JsonExecutor>
Base for extension endpoint specs whose request is path/query parameters and
an optional JSON object body, and whose response is a JSON value - the
common shape of module and qbit endpoints. A subclass defines the operation
(path, method, parameters, request and response schemas) and handle(); the
session is set up (for secured specs) before handle runs, and the result is
written as JSON with nulls kept.
Each subclass needs a public no-arg constructor (it is registered by class
in a MiddlewareSpecExtension). See docs/UI-API-EXTENSIONS.md.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classruns the spec's handle()static classThe request: path parameters, the first value of each query parameter, and the JSON body (empty unless the spec defines one).static classthe response bodystatic interfaceoutput interface -
Field Summary
Fields inherited from class com.kingsrook.qqq.middleware.javalin.specs.AbstractEndpointSpec
qInstance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildInput(io.javalin.http.Context context) build the endpoint's input object from a javalin contextprotected SchemaThe schema of the JSON request body, or null (the default) for none.protected abstract StringThe component schema name of the 200 response body.protected abstract ObjectDo the operation's work (the QContext has the session for a secured spec) and return the response body (serialized to JSON).voidhandleOutput(io.javalin.http.Context context, AbstractJsonEndpointSpec.JsonOutput output) build the endpoint's http response (written to the javalin context) from an execution output objectMethods inherited from class com.kingsrook.qqq.middleware.javalin.specs.AbstractEndpointSpec
checkCredentialScopeOperation, customizeMethod, defineAdditionalBasicResponses, defineBasicOperation, defineCompleteOperation, defineComponentSchemas, defineMethod, defineRequestParameters, defineResponses, defineRoute, getOperationId, getRequestBodyAsJsonObject, getRequestParam, getRequestParamInteger, getRequestParamMap, handleException, isSecured, newExecutor, newOutput, serveRequest, setQInstance
-
Constructor Details
-
AbstractJsonEndpointSpec
public AbstractJsonEndpointSpec()
-
-
Method Details
-
handle
Do the operation's work (the QContext has the session for a secured spec) and return the response body (serialized to JSON).- Throws:
Exception
-
getResponseSchemaName
The component schema name of the 200 response body. -
defineRequestBodySchema
The schema of the JSON request body, or null (the default) for none. -
defineRequestBody
-
defineBasicSuccessResponse
-
buildInput
public AbstractJsonEndpointSpec.JsonInput buildInput(io.javalin.http.Context context) throws Exception Description copied from class:AbstractEndpointSpecbuild the endpoint's input object from a javalin context- Specified by:
buildInputin classAbstractEndpointSpec<AbstractJsonEndpointSpec.JsonInput,AbstractJsonEndpointSpec.JsonOutput, AbstractJsonEndpointSpec.JsonExecutor> - Throws:
Exception
-
handleOutput
public void handleOutput(io.javalin.http.Context context, AbstractJsonEndpointSpec.JsonOutput output) throws Exception Description copied from class:AbstractEndpointSpecbuild the endpoint's http response (written to the javalin context) from an execution output object
-