Skip to main content

A Robot Framework library to facilitate library development for OpenAPI / Swagger APIs.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description



OpenApiLibCore for Robot Framework®

The OpenApiLibCore library is a utility library that is meant to simplify creation of other Robot Framework libraries for API testing based on the information in an OpenAPI document (also known as Swagger document). This document explains how to use the OpenApiLibCore library.

For more information about Robot Framework®, see http://robotframework.org.


Note: OpenApiLibCore is still being developed so there are currently restrictions / limitations that you may encounter when using this library to run tests against an API. See Limitations for details.


Installation

If you already have Python >= 3.8 with pip installed, you can simply run:

pip install --upgrade robotframework-openapi-libcore


OpenAPI (aka Swagger)

The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs, see https://swagger.io/specification/

The OpenApiLibCore implements a number of Robot Framework keywords that make it easy to interact with an OpenAPI implementation by using the information in the openapi document (Swagger file), for examply by automatic generation of valid values for requests based on the schema information in the document.

Note: OpenApiLibCore is designed for APIs based on the OAS v3 The library has not been tested for APIs based on the OAS v2.


Getting started

Before trying to use the keywords exposed by OpenApiLibCore on the target API it's recommended to first ensure that the openapi document for the API is valid under the OpenAPI Specification.

This can be done using the command line interface of a package that is installed as a prerequisite for OpenApiLibCore. Both a local openapi.json or openapi.yaml file or one hosted by the API server can be checked using the prance validate <reference_to_file> shell command:

prance validate http://localhost:8000/openapi.json
Processing "http://localhost:8000/openapi.json"...
 -> Resolving external references.
Validates OK as OpenAPI 3.0.2!

prance validate /tests/files/petstore_openapi.yaml
Processing "/tests/files/petstore_openapi.yaml"...
 -> Resolving external references.
Validates OK as OpenAPI 3.0.2!

You'll have to change the url or file reference to the location of the openapi document for your API.

If the openapi document passes this validation, the next step is trying to do a test run with a minimal test suite. The example below can be used, with source, origin and 'endpoint' altered to fit your situation.

*** Settings ***
Library            OpenApiLibCore
...                    source=http://localhost:8000/openapi.json
...                    origin=http://localhost:8000

*** Test Cases ***
Getting Started
    ${url}=    Get Valid Url    endpoint=/employees/{employee_id}   method=get

Running the above suite for the first time may result in an error / failed test. You should look at the Robot Framework log.html to determine the reasons for the failing tests. Depending on the reasons for the failures, different solutions are possible.

Details about the OpenApiLibCore library parameters and keywords that you may need can be found here.

The OpenApiLibCore also support handling of relations between resources within the scope of the API being validated as well as handling dependencies on resources outside the scope of the API. In addition there is support for handling restrictions on the values of parameters and properties.

Details about the mappings_path variable usage can be found here.


Limitations

There are currently a number of limitations to supported API structures, supported data types and properties. The following list details the most important ones:

  • Only JSON request and response bodies are currently supported.
  • The unique identifier for a resource as used in the paths section of the openapi document is expected to be the id property on a resource of that type.
  • Limited support for query strings and headers.
  • Limited support for authentication
    • username and password can be passed as parameters to use Basic Authentication
    • A requests AuthBase instance can be passed and it will be used as provided.
    • No support for per-endpoint authorization levels (just simple 401 validation).
  • byte, binary, date, date-time string formats not supported yet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework-openapi-libcore-1.1.1.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file robotframework-openapi-libcore-1.1.1.tar.gz.

File metadata

File hashes

Hashes for robotframework-openapi-libcore-1.1.1.tar.gz
Algorithm Hash digest
SHA256 62a685d13cc1c359300aae7f0bed267aea2cc6536eee09d76f9867923459e686
MD5 75380f521e92e162acc93da230efe485
BLAKE2b-256 09045557adf2c3b7d802a83e9b7a3a65425e75ee1ef64fd781e1fdc9bd32b638

See more details on using hashes here.

File details

Details for the file robotframework_openapi_libcore-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_openapi_libcore-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bbe267f5666fa2e63d5d6eaae164f7970f41a532816cdb560fe7aa18df74a15
MD5 f2c05a8de0a2b4c467aade9fb819d45d
BLAKE2b-256 fcd3350d45bf5fefc88d2ded86b9fb065e3387726b7daad3b29e6b20a2ac2c3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page