Page Contents

Home > @loopback/openapi-spec-builder

openapi-spec-builder package

A package to simplify creating OpenAPI specification documents in your tests using the builder pattern.


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 to provide a TypeScript/JavaScript API allowing users to create full OpenAPI Specification 3 documents in few lines of code.


Class Description
ComponentsSpecBuilder A builder for creating ComponentsObject specifications.
OpenApiSpecBuilder A builder for creating OpenApiSpec documents.
OperationSpecBuilder A builder for creating OperationObject specifications.


Function Description
aComponentsSpec() Create a new instance of ComponentsSpecBuilder.
anOpenApiSpec() Create a new instance of OpenApiSpecBuilder.
anOperationSpec() Create a new instance of OperationSpecBuilder.