swaggerpy.client module

Swagger client library.

class swaggerpy.client.ClientProcessor[source]

Bases: SwaggerProcessor

Enriches swagger models for client processing.

process_resource_listing_api(resources, listing_api, context)[source]

Add name to listing_api.

Parameters
  • resources – Resource listing object

  • listing_api – ResourceApi object.

  • context (ParsingContext) – Current context in the API.

class swaggerpy.client.Operation(uri, operation, http_client)[source]

Bases: object

Operation object.

class swaggerpy.client.Resource(resource, http_client)[source]

Bases: object

Swagger resource, described in an API declaration.

Parameters
  • resource – Resource model

  • http_client – HTTP client API

get_name()[source]

Returns the name of this resource.

Name is derived from the filename of the API declaration.

Returns

Resource name.

get_operation(name)[source]

Gets the operation with the given nickname.

Parameters

name – Nickname of the operation.

Return type

Operation

Returns

Operation, or None if not found.

class swaggerpy.client.SwaggerClient(url_or_resource, http_client=None)[source]

Bases: object

Client object for accessing a Swagger-documented RESTful service.

Parameters
  • url_or_resource (dict or str) – Either the parsed resource listing+API decls, or its URL.

  • http_client (HttpClient) – HTTP client API

close()[source]

Close the SwaggerClient, and underlying resources.

get_resource(name)[source]

Gets a Swagger resource by name.

Parameters

name – Name of the resource to get

Return type

Resource

Returns

Resource, or None if not found.