---
lang: en
title: 'API docs: openapi-spec-builder.operationspecbuilder'
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.operationspecbuilder.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) &gt; [OperationSpecBuilder](./openapi-spec-builder.operationspecbuilder.md)

## OperationSpecBuilder class

A builder for creating OperationObject specifications.

**Signature:**

```typescript
export declare class OperationSpecBuilder extends BuilderBase<OperationObject> 
```
**Extends:** [BuilderBase](./openapi-spec-builder.builderbase.md)<!-- -->&lt;OperationObject&gt;

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)()](./openapi-spec-builder.operationspecbuilder._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `OperationSpecBuilder` class


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[withControllerName(name)](./openapi-spec-builder.operationspecbuilder.withcontrollername.md)


</td><td>


</td><td>

Define the controller name (controller name).


</td></tr>
<tr><td>

[withOperationId(operationId)](./openapi-spec-builder.operationspecbuilder.withoperationid.md)


</td><td>


</td><td>

Define the operationId


</td></tr>
<tr><td>

[withOperationName(name)](./openapi-spec-builder.operationspecbuilder.withoperationname.md)


</td><td>


</td><td>

Define the operation name (controller method name).


</td></tr>
<tr><td>

[withParameter(parameterSpecs)](./openapi-spec-builder.operationspecbuilder.withparameter.md)


</td><td>


</td><td>

Describe one more parameters accepted by the operation. Note that parameters are positional in OpenAPI Spec, therefore the first call of `withParameter` defines the first parameter, the second call defines the second parameter, etc.


</td></tr>
<tr><td>

[withRequestBody(requestBodySpec)](./openapi-spec-builder.operationspecbuilder.withrequestbody.md)


</td><td>


</td><td>


</td></tr>
<tr><td>

[withResponse(status, responseSpec)](./openapi-spec-builder.operationspecbuilder.withresponse.md)


</td><td>


</td><td>

Describe a response for a given HTTP status code.


</td></tr>
<tr><td>

[withStringResponse(status)](./openapi-spec-builder.operationspecbuilder.withstringresponse.md)


</td><td>


</td><td>


</td></tr>
<tr><td>

[withTags(tags)](./openapi-spec-builder.operationspecbuilder.withtags.md)


</td><td>


</td><td>

Describe tags associated with the operation


</td></tr>
</tbody></table>

