Swagger Client exposes these functionalities for OpenAPI 2.0 and OpenAPI 3:
- Static methods for...
- HTTP Client (
http
) - Document Resolver (monolithic & subtree) (
resolve
,resolveSubtree
) - HTTP client for OAS operations (
buildRequest
,execute
)
- HTTP Client (
- A constructor with the methods...
- HTTP Client, for convenience (
http
) - Document Resolver, which will use
url
orspec
from the instance (resolve
) - HTTP client for OAS operations, bound to the
http
andspec
instance properties (execute
) - Tags Interface, also bound to the instance
- HTTP Client, for convenience (
It is also possible to use SwaggerClient without explicitly instantiating the constructor.
import SwaggerClient from 'swagger-client';
new SwaggerClient('http://petstore.swagger.io/v2/swagger.json');
SwaggerClient('http://petstore.swagger.io/v2/swagger.json');
// these two lines are equivalent
If you call the constructor as function, constructor is instantiated for you implicitly.