Skip to main content

A library for contract-testing OpenAPI / Swagger APIs.

Project description

OpenDriver 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.

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. https://swagger.io/specification/

The openapi 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 prance module 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.

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-0.1.0a5.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file robotframework-openapidriver-0.1.0a5.tar.gz.

File metadata

File hashes

Hashes for robotframework-openapidriver-0.1.0a5.tar.gz
Algorithm Hash digest
SHA256 492e6911637e3df707b60ab36b50844d6f6fe38516294b37a9344680e9d62930
MD5 380cd4c07e9a1d5528d0c4e96291570b
BLAKE2b-256 fcab44f975379bbd7da1fa7dd3f41d9dcda6dae04f27fb9ed0af8226e2f5179e

See more details on using hashes here.

File details

Details for the file robotframework_openapidriver-0.1.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_openapidriver-0.1.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 c4c87f8ba0f27f78fe890f5c8c05d7c3ef60d5781e4a2080500e410fc09c1d23
MD5 79fd69bbb62bc6716c2bb1a9bda30ebc
BLAKE2b-256 5b2d9c9d7ecec3e19a40d7d203031038926ba2c19b350180f43b837fd50eeb1b

See more details on using hashes here.

Supported by

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