---
lang: en
title: 'API docs: openapi-spec-builder'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/openapi-spec-builder
permalink: /doc/en/lb4/apidocs.openapi-spec-builder.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/openapi-spec-builder](./openapi-spec-builder.md)

## openapi-spec-builder package

A package to simplify creating OpenAPI specification documents in your tests using the builder pattern.

## Remarks

Creating a full OpenAPI spec document in automated tests is rather cumbersome, long JSON-like objects pollute the test test code and make it difficult for readers to distinguish between what's important in the test and what's just shared OpenAPI boilerplate.

OpenApiSpecBuilder utilizes [Test Data Builder pattern](http://www.natpryce.com/articles/000714.html) to provide a TypeScript/JavaScript API allowing users to create full OpenAPI Specification 3 documents in few lines of code.

## Classes

<table><thead><tr><th>

Class


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

[BuilderBase](./openapi-spec-builder.builderbase.md)


</td><td markdown="1">


</td></tr>
<tr><td markdown="1">

[ComponentsSpecBuilder](./openapi-spec-builder.componentsspecbuilder.md)


</td><td markdown="1">

A builder for creating ComponentsObject specifications.


</td></tr>
<tr><td markdown="1">

[OpenApiSpecBuilder](./openapi-spec-builder.openapispecbuilder.md)


</td><td markdown="1">

A builder for creating OpenApiSpec documents.


</td></tr>
<tr><td markdown="1">

[OperationSpecBuilder](./openapi-spec-builder.operationspecbuilder.md)


</td><td markdown="1">

A builder for creating OperationObject specifications.


</td></tr>
</tbody></table>

## Functions

<table><thead><tr><th>

Function


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

[aComponentsSpec()](./openapi-spec-builder.acomponentsspec.md)


</td><td markdown="1">

Create a new instance of ComponentsSpecBuilder.


</td></tr>
<tr><td markdown="1">

[anOpenApiSpec()](./openapi-spec-builder.anopenapispec.md)


</td><td markdown="1">

Create a new instance of OpenApiSpecBuilder.


</td></tr>
<tr><td markdown="1">

[anOperationSpec()](./openapi-spec-builder.anoperationspec.md)


</td><td markdown="1">

Create a new instance of OperationSpecBuilder.


</td></tr>
</tbody></table>


