Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 2.66 KB

open-api.mdx

File metadata and controls

62 lines (42 loc) · 2.66 KB
sidebar_label sidebar_position description keywords sidebar_class_name
OpenAPI spec import
4
Import an Action from an OpenAPI spec
hasura
docs
actions
import
openapi
cloud-and-enterprise-icon

import Thumbnail from '@site/src/components/Thumbnail';

Import Action from OpenAPI Spec

Available on: Cloud, Enterprise Edition

Overview

The most common use case for Actions is to expose an existing API as a GraphQL query. To make this easier, we have added the ability to import an Action from an OpenAPI spec. OpenAPI is a widely used standard for describing REST APIs, and many APIs already have an OpenAPI spec available. This feature allows you to upload an OpenAPI spec, select the operation you want to expose as an Action, and Hasura will automatically prepopulate the Action definition for you.

:::caution Import Action from OpenAPI Spec availability

The Import Action from OpenAPI Spec feature is currently available in alpha for all Hasura Cloud offerings and for Hasura Enterprise Edition (EE) customers. Once it is generally available (GA), it will be available only for Hasura Cloud Enterprise and EE customers.

:::

Enabling the feature

While the Import Action from OpenAPI Spec is in alpha, the feature can only be enabled by turning on the Import from OpenAPI under the Feature Flags section of the Console configuration page.

Click the gear icon (1) in the top-right corner of your Cloud project; in the side navigation, click "Feature Flags" (2); finally, toggle the "Import Action from OpenAPI" switch to enable (3).

Importing an Action from an OpenAPI spec

After enabling the feature, you can import an Action from an OpenAPI spec by clicking the "Create" button from the Actions page of the Console. You should see a new option to Import from OpenAPI, click this to start the import:

Either select a file (YAML or JSON) or paste the contents of an OpenAPI spec into the text box. Then, select an endpoint and click Generate Action:

From the Actions page, you can further customize the Action definition, and then click "Create" to create the Action:

You can now use this imported Action in your GraphQL API!