steampipe plugin install openapi

Table: openapi_component_header - Query OpenAPI Components using SQL

OpenAPI Components provide a standardized way to design and describe APIs, enabling interoperability and consistency across different services. They are a crucial part of the OpenAPI Specification, which is a widely adopted standard for designing and documenting APIs. Components, such as headers, provide reusable building blocks for the API, reducing redundancy and promoting reuse across the API.

Table Usage Guide

The openapi_component_header table provides insights into the headers of OpenAPI components. As a developer or API designer, explore header-specific details through this table, including parameters, types, and associated metadata. Utilize it to uncover information about headers, such as their data types, required status, and description, aiding in the design, documentation, and understanding of APIs.

Examples

Basic info

Explore the key aspects of an OpenAPI component such as its name, location, and description to gain insights into its configuration and understand its role within the overall system. This can be particularly useful in identifying potential areas for optimization or troubleshooting.

select
key,
name,
location,
description,
path
from
openapi_component_header;
select
key,
name,
location,
description,
path
from
openapi_component_header;

List unused header definitions

Determine unused header definitions in your API's OpenAPI specification. This helps to maintain a lean and efficient API documentation by identifying and removing redundant header definitions.

with list_available_headers as (
select
path,
array_agg(key) as header_refs
from
openapi_component_header
group by
path
),
list_used_headers as (
select
path,
array_agg(distinct split_part(value ->> '$ref', '/', '4')) as headers
from
openapi_path_response,
jsonb_each(headers)
where
(value ->> '$ref') is not null
group by
path
),
unused_headers_definitions as (
select
path,
unnest(header_refs) as data
from
list_available_headers
except
select
path,
unnest(headers) as data
from
list_used_headers
)
select
path,
concat('components.headers.', data) as header_ref
from
unused_headers_definitions;
Error: SQLite does not support array_agg,
split_part,
and unnest functions.

List headers with no schema

Explore which headers in your OpenAPI components are missing a schema, helping to identify potential areas for further definition and structure. This can be particularly useful for maintaining consistency and clarity in your API documentation.

select
key,
location,
deprecated,
description,
path
from
openapi_component_header
where
schema is null
and schema_ref is null;
select
key,
location,
deprecated,
description,
path
from
openapi_component_header
where
schema is null
and schema_ref is null;

List deprecated headers with no alternative mentioned in the description

Identify instances where deprecated headers are being used without any alternative mentioned. This can help in updating your API usage to avoid potential issues in the future.

select
key,
location,
deprecated,
description,
path
from
openapi_component_header
where
deprecated
and description is null;
select
key,
location,
deprecated,
description,
path
from
openapi_component_header
where
deprecated
and description is null;

Schema for openapi_component_header

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