Page Contents

Home > @loopback/openapi-v3

openapi-v3 package

Decorators that describe LoopBack artifacts as OpenAPI 3.0.0 metadata and utilities that transfer LoopBack metadata to OpenAPI 3.0.0 specifications.

Remarks

The package has functions described above for LoopBack controller classes. Decorators apply REST api mapping metadata to controller classes and their members. And utilities that inspect controller classes to build OpenAPI 3.0.0 specifications from REST API mapping metadata.

Functions for more artifacts will be added when needed.

Classes

Class Description
[OASEnhancerService](/doc/en/lb4/apidocs.openapi-v3.oasenhancerservice.html) An extension point for OpenAPI Spec enhancement This service is used for enhancing an OpenAPI spec by loading and applying one or more registered enhancers. A typical use of it would be generating the OpenAPI spec for the endpoints on a server in the `@loopback/rest` module.

Enumerations

Enumeration Description
[OperationVisibility](/doc/en/lb4/apidocs.openapi-v3.operationvisibility.html)

Functions

Function Description
[api(spec)](/doc/en/lb4/apidocs.openapi-v3.api.html) Decorate the given Controller constructor with metadata describing the HTTP/REST API the Controller implements/provides. `@api` can be applied to controller classes.
[createEmptyApiSpec()](/doc/en/lb4/apidocs.openapi-v3.createemptyapispec.html) Create an empty OpenApiSpec object that's still a valid openapi document.
[del(path, spec)](/doc/en/lb4/apidocs.openapi-v3.del.html) Expose a Controller method as a REST API operation mapped to `DELETE` request method.
[deprecated(isDeprecated)](/doc/en/lb4/apidocs.openapi-v3.deprecated.html) Marks an api path as deprecated. When applied to a class, this decorator marks all paths as deprecated. You can optionally mark all controllers in a class as deprecated, but use `@deprecated(false)` on a specific method to ensure it is not marked as deprecated in the specification.
[get(path, spec)](/doc/en/lb4/apidocs.openapi-v3.get.html) Expose a Controller method as a REST API operation mapped to `GET` request method.
[getControllerSpec(constructor)](/doc/en/lb4/apidocs.openapi-v3.getcontrollerspec.html) Get the controller spec for the given class
[getFilterSchemaFor(modelCtor, options)](/doc/en/lb4/apidocs.openapi-v3.getfilterschemafor.html) Build an OpenAPI schema describing the format of the "filter" object used to query model instances. Note we don't take the model properties into account yet and return a generic json schema allowing any "where" condition.
[getModelSchemaRef(modelCtor, options)](/doc/en/lb4/apidocs.openapi-v3.getmodelschemaref.html) Describe the provided Model as a reference to a definition shared by multiple endpoints. The definition is included in the returned schema.
[getWhereSchemaFor(modelCtor)](/doc/en/lb4/apidocs.openapi-v3.getwhereschemafor.html) Build a OpenAPI schema describing the format of the "where" object used to filter model instances to query, update or delete. Note we don't take the model properties into account yet and return a generic json schema allowing any "where" condition.
[jsonOrBooleanToJSON(jsonOrBool)](/doc/en/lb4/apidocs.openapi-v3.jsonorbooleantojson.html) Helper function used to interpret boolean values as JSON Schemas. See http://json-schema.org/draft-06/json-schema-release-notes.html
[jsonToSchemaObject(json, visited)](/doc/en/lb4/apidocs.openapi-v3.jsontoschemaobject.html) Converts JSON Schemas into a SchemaObject
[mergeOpenAPISpec(currentSpec, patchSpec)](/doc/en/lb4/apidocs.openapi-v3.mergeopenapispec.html) The default merge function to patch the current OpenAPI spec. It leverages module `json-merge-patch`'s merge API to merge two json objects. It returns a new merged object without modifying the original one. A list of merging rules can be found in test file: https://github.com/pierreinglebert/json-merge-patch/blob/master/test/lib/merge.js
[mergeSecuritySchemeToSpec(spec, schemeName, schemeSpec)](/doc/en/lb4/apidocs.openapi-v3.mergesecurityschemetospec.html) Security scheme merge helper function to patch the current OpenAPI spec. It provides a direct route to add a security schema to the specs components. It returns a new merged object without modifying the original one.
[operation(verb, path, spec)](/doc/en/lb4/apidocs.openapi-v3.operation.html) Expose a Controller method as a REST API operation.
[param(paramSpec)](/doc/en/lb4/apidocs.openapi-v3.param.html) Describe an input parameter of a Controller method. `@param` must be applied to parameters.
[patch(path, spec)](/doc/en/lb4/apidocs.openapi-v3.patch.html) Expose a Controller method as a REST API operation mapped to `PATCH` request method.
[post(path, spec)](/doc/en/lb4/apidocs.openapi-v3.post.html) Expose a Controller method as a REST API operation mapped to `POST` request method.
[put(path, spec)](/doc/en/lb4/apidocs.openapi-v3.put.html) Expose a Controller method as a REST API operation mapped to `PUT` request method.
[requestBody(requestBodySpec)](/doc/en/lb4/apidocs.openapi-v3.requestbody.html) Describe the request body of a Controller method parameter. A typical OpenAPI requestBody spec contains property: - `description` - `required` - `content`.
[response(responseCode, responseModelOrSpec)](/doc/en/lb4/apidocs.openapi-v3.response.html) Add response object to a path spec.
[tags(tagNames)](/doc/en/lb4/apidocs.openapi-v3.tags.html) Add tags for an endpoint. When applied to a class, this decorator adds the tags to all endpoints.
[visibility(visibilityType)](/doc/en/lb4/apidocs.openapi-v3.visibility.html) Marks an api path with the specfied visibility. When applied to a class, this decorator marks all paths with the specified visibility. You can optionally mark all controllers in a class with `@visibility('undocumented')`, but use `@visibility('documented')` on a specific method to ensure it is not marked as `undocumented`.

Interfaces

Interface Description
[ControllerSpec](/doc/en/lb4/apidocs.openapi-v3.controllerspec.html)
[OASEnhancer](/doc/en/lb4/apidocs.openapi-v3.oasenhancer.html) Typically an extension point defines an interface as the contract for extensions to implement
[OASEnhancerServiceOptions](/doc/en/lb4/apidocs.openapi-v3.oasenhancerserviceoptions.html) Options for the OpenAPI Spec enhancer extension point
[ResponseDecoratorMetadataItem](/doc/en/lb4/apidocs.openapi-v3.responsedecoratormetadataitem.html)
[RestEndpoint](/doc/en/lb4/apidocs.openapi-v3.restendpoint.html) Data structure for REST related metadata
[TagsDecoratorMetadata](/doc/en/lb4/apidocs.openapi-v3.tagsdecoratormetadata.html)

Namespaces

Namespace Description
[OASEnhancerBindings](/doc/en/lb4/apidocs.openapi-v3.oasenhancerbindings.html)
[param](/doc/en/lb4/apidocs.openapi-v3.param.html) Namespace for `@param.*` decorators
[requestBody](/doc/en/lb4/apidocs.openapi-v3.requestbody.html)
[response](/doc/en/lb4/apidocs.openapi-v3.response.html)

Variables

Variable Description
[asSpecEnhancer](/doc/en/lb4/apidocs.openapi-v3.asspecenhancer.html) A binding template for spec contributor extensions
[DEFAULT\_OPENAPI\_SPEC\_INFO](/doc/en/lb4/apidocs.openapi-v3.default_openapi_spec_info.html)
[oas](/doc/en/lb4/apidocs.openapi-v3.oas.html)
[PARAMETER\_INDEX](/doc/en/lb4/apidocs.openapi-v3.parameter_index.html)
[REQUEST\_BODY\_INDEX](/doc/en/lb4/apidocs.openapi-v3.request_body_index.html)
[TS\_TYPE\_KEY](/doc/en/lb4/apidocs.openapi-v3.ts_type_key.html)

Type Aliases

Type Alias Description
[OpenApiSpec](/doc/en/lb4/apidocs.openapi-v3.openapispec.html)
[ResponseDecoratorMetadata](/doc/en/lb4/apidocs.openapi-v3.responsedecoratormetadata.html)
[ResponseModelOrSpec](/doc/en/lb4/apidocs.openapi-v3.responsemodelorspec.html)
[SchemaRef](/doc/en/lb4/apidocs.openapi-v3.schemaref.html) Custom LoopBack extension: a reference to Schema object that's bundled inside `definitions` property.