steampipe plugin install openapi

Table: openapi_component_parameter - Query OpenAPI Components using SQL

OpenAPI is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful web services. It provides a way to describe and document RESTful APIs in a common language that everyone can understand. It is particularly useful for creating API documentation, generating code and ensuring that the APIs you build are simple, fast, and consistently well-structured.

Table Usage Guide

The openapi_component_parameter table provides insights into the parameters of each component within OpenAPI. As a developer or API architect, explore parameter-specific details through this table, including their names, descriptions, and whether they are required. Utilize it to uncover information about parameters, such as their data types, default values, and whether they allow empty values, helping to ensure your APIs are well-structured and follow best practices.

Examples

Basic info

Explore the parameters of an OpenAPI component to understand their usage, including whether they are required or deprecated. This can assist in identifying areas for potential improvements or updates within your API structure.

select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter;
select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter;

List all supported parameters for a specific API endpoint

Explore the different specifications of parameters for a particular API endpoint. This is useful to understand the requirements and potential deprecations for each parameter, aiding in effective API usage and maintenance.

with list_parameters as (
select
api_path,
p ->> '$ref' as parameter_ref
from
openapi_path,
jsonb_array_elements(parameters) as p
where
api_path = '/repos/{owner}/{repo}/issues/post'
)
select
l.api_path,
p.name as parameter_name,
p.required as is_required,
p.deprecated as is_deprecated,
jsonb_pretty(p.schema) as parameter_schema
from
list_parameters as l
join openapi_component_parameter as p on l.parameter_ref = concat('#/components/parameters/', p.name);
with list_parameters as (
select
api_path,
json_extract(p.value, '$."$ref"') as parameter_ref
from
openapi_path,
json_each(parameters) as p
where
api_path = '/repos/{owner}/{repo}/issues/post'
)
select
l.api_path,
p.name as parameter_name,
p.required as is_required,
p.deprecated as is_deprecated,
p.schema as parameter_schema
from
list_parameters as l
join openapi_component_parameter as p on l.parameter_ref = '#/components/parameters/' || p.name;

List parameters with no schema

Discover the segments that have parameters without a defined schema, which can help identify potential areas of improvement or inconsistencies within your OpenAPI components. This could be particularly useful in maintaining or upgrading your API systems.

select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter
where
schema is null
and schema_ref is null;
select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter
where
schema is null
and schema_ref is null;

List deprecated parameters with no alternative mentioned in the description

Explore which parameters in your OpenAPI components are deprecated but lack a description, helping you to identify potential issues in your API documentation and ensure all deprecated parameters are correctly documented for future reference.

select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter
where
deprecated
and description is null;
select
name,
description,
location,
deprecated,
required,
schema,
path
from
openapi_component_parameter
where
deprecated = 1
and description is null;

Schema for openapi_component_parameter

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
allow_empty_valuebooleanIf true, an empty value can be set to the parameter.
allow_reservedbooleanDetermines whether the parameter value should allow reserved characters, as defined by RFC3986 (e.g. :/?#[]@!$&'()*+,;=) to be included without percent-encoding. This property only applies to parameters with an in value of query. The default value is false.
deprecatedbooleanTrue, if the parameter is deprecated.
descriptiontextA brief description of the parameter.
explodebooleanIf true, parameter values of type array or object generate separate parameters for each value of the array or key-value pair of the map.
keytextThe key used to refer or search the parameter.
locationtextThe location of the parameter. Possible values are query, header, path or cookie.
nametextThe name of the parameter.
pathtext=Path to the file.
requiredbooleanTrue, if the parameter is required.
schemajsonbThe schema of the parameter.
schema_reftextThe schema reference of the parameter.
styletextDescribes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of in): for query - form; for path - simple; for header - simple; for cookie - form.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- openapi

You can pass the configuration to the command with the --config argument:

steampipe_export_openapi --config '<your_config>' openapi_component_parameter