The Tags Interface transforms OpenAPI Specification (OAS) operationIds into callable JavaScript functions. Each function returns a Promise that resolves to a Response.
How operations are mapped to function names:
- With
operationId: The operationId is used directly. - Without
operationId: A name is deduced from the HTTP method and path (e.g., ${method}${pathName}), with non-alphanumeric characters replaced by _. - Missing Tags: If an operation has no tag, it is grouped under the
default tag in the client.apis object. - Duplicate
operationIds: If IDs are duplicated, they are renamed with numbers (e.g., operation1, operation2) to ensure uniqueness.
import SwaggerClient from 'swagger-client';
// Example: Calling an operation with an operationId
new SwaggerClient({ spec })
.then(client => client.apis.default.getUserById(...));
// Example: Calling a deduced operation (method + path)
new SwaggerClient({ spec })
.then(client => client.apis.default.getOne(...));