---
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/strongloop/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

|  Class | Description |
|  --- | --- |
|  [BuilderBase](./openapi-spec-builder.builderbase.md) |  |
|  [ComponentsSpecBuilder](./openapi-spec-builder.componentsspecbuilder.md) | A builder for creating ComponentsObject specifications. |
|  [OpenApiSpecBuilder](./openapi-spec-builder.openapispecbuilder.md) | A builder for creating OpenApiSpec documents. |
|  [OperationSpecBuilder](./openapi-spec-builder.operationspecbuilder.md) | A builder for creating OperationObject specifications. |

## Functions

|  Function | Description |
|  --- | --- |
|  [aComponentsSpec()](./openapi-spec-builder.acomponentsspec.md) | Create a new instance of ComponentsSpecBuilder. |
|  [anOpenApiSpec()](./openapi-spec-builder.anopenapispec.md) | Create a new instance of OpenApiSpecBuilder. |
|  [anOperationSpec()](./openapi-spec-builder.anoperationspec.md) | Create a new instance of OperationSpecBuilder. |


