Skip to main content

A library for contract-testing 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



OpenApiDriver for Robot Framework®

OpenApiDriver is an extension of the Robot Framework® DataDriver library that allows for generation and execution of test cases based on the information in an OpenAPI document (also known as Swagger document). This document explains how to use the OpenApiDriver library.

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

For more information about the DataDriver library, see https://github.com/Snooz82/robotframework-datadriver.


Note: OpenApiDriver is currently in early development 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-openapidriver


OpenAPI (aka Swagger)

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

The OpenApiDriver module implements a reader class that generates a test case for each endpoint, method and response that is defined in an OpenAPI document, typically an openapi.json or openapi.yaml file.


How it works

If the source file has the .json or .yaml extension, it will be loaded by the library (using the prance library under the hood) and the test cases will be generated.

*** Settings ***
Library            OpenApiDriver
...                    source=openapi.json
Test Template      Do Nothing


*** Test Cases ***
Some OpenAPI test for ${method} on ${endpoint} where ${status_code} is expected

*** Keywords *** ***
Do Nothing
    [Arguments]    ${endpoint}    ${method}    ${status_code}
    No Operation

It is also possible to load the openapi.json / openapi.yaml directly from the server by using the url instead of a local file:

*** Settings ***
Library            OpenApiDriver
...                    source=http://127.0.0.1:8000/openapi.json

Since the OpenAPI document is essentially a contract that specifies what operations are supported and what data needs to be send and will be returned, it is possible to automatically validate the API against this contract. For this purpose, the openapi module also implements a number of keywords.

Details about the Keywords 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.
  • The id is expected to be a UUID (v4).
  • No support for query strings at this time.
  • No support for 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).
  • exclusiveMinimum and exclusiveMaximum not supported yet.
  • 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-openapidriver-1.0.0b0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

robotframework_openapidriver-1.0.0b0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file robotframework-openapidriver-1.0.0b0.tar.gz.

File metadata

File hashes

Hashes for robotframework-openapidriver-1.0.0b0.tar.gz
Algorithm Hash digest
SHA256 b606cb953f4431cb8a6aa8415db4399e3acc7cb856837b1231c39602e7e4fce6
MD5 89359fd3d07ded5d20ac3a7333af3dcc
BLAKE2b-256 6ab53beece7851d5dbcc4a5a7684ec8a59744decca893e926c2a0affc3baceef

See more details on using hashes here.

File details

Details for the file robotframework_openapidriver-1.0.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_openapidriver-1.0.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a51a15709929aeb8d6c459569f96f399f518a373511f91506463b23858ed488
MD5 d0a868fbc3d34a6db74d21e32c9868d4
BLAKE2b-256 9dcdd4e985cb568d1f090a0ba0aab3e0679c8ac9871b4ce9ff76150656219c6c

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