feat: move openapi utils into separate package

pull/715/head
Travis Fischer 2025-05-25 06:41:51 +07:00
rodzic 8f0e3f2cfa
commit 0157870fcf
18 zmienionych plików z 6194 dodań i 23 usunięć

Wyświetl plik

@ -27,6 +27,7 @@
},
"dependencies": {
"@agentic/platform-core": "workspace:*",
"@agentic/platform-openapi": "workspace:*",
"@agentic/platform-schemas": "workspace:*",
"@agentic/platform-validators": "workspace:*",
"@fisch0920/drizzle-orm": "^0.43.7",
@ -36,7 +37,6 @@
"@hono/zod-openapi": "^0.19.6",
"@openauthjs/openauth": "^0.4.3",
"@paralleldrive/cuid2": "^2.2.2",
"@redocly/openapi-core": "^1.34.3",
"@sentry/node": "^9.19.0",
"eventid": "^2.0.1",
"exit-hook": "catalog:",
@ -53,7 +53,6 @@
"devDependencies": {
"@types/semver": "^7.7.0",
"drizzle-kit": "^0.31.1",
"drizzle-orm": "^0.43.1",
"openapi-typescript": "^7.8.0"
"drizzle-orm": "^0.43.1"
}
}

Wyświetl plik

@ -1,8 +1,8 @@
import type { DeploymentOriginAdapter } from '@agentic/platform-schemas'
import { assert } from '@agentic/platform-core'
import { validateOpenAPISpec } from '@agentic/platform-openapi'
import type { Logger } from '@/lib/logger'
import { validateOpenAPISpec } from '@/lib/validate-openapi-spec'
/**
* Validates and normalizes the origin adapter config for a deployment.

Wyświetl plik

@ -5,8 +5,6 @@ import type { RawTeamMember, RawUser } from '@/db'
import type { Env } from './env'
import type { Logger } from './logger'
export type { OpenAPI3 as LooseOpenAPI3Spec } from 'openapi-typescript'
export type Environment = Env['NODE_ENV']
export type Service = 'api'

Wyświetl plik

@ -0,0 +1,41 @@
{
"openapi": "3.0.2",
"info": {
"title": "OpenAPI Basic Test Fixture",
"version": "0.1.0"
},
"paths": {
"/": {
"get": {
"summary": "Echo",
"operationId": "echo",
"parameters": [
{
"required": false,
"schema": {
"title": "name",
"type": "string"
},
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://test-openapi-basic.now.sh"
}
]
}

Wyświetl plik

@ -0,0 +1,936 @@
{
"openapi": "3.0.0",
"info": {
"title": "Firecrawl API",
"version": "1.0.0",
"description": "API for interacting with Firecrawl services to perform web scraping and crawling tasks.",
"contact": {
"name": "Firecrawl Support",
"url": "https://firecrawl.dev/support",
"email": "support@firecrawl.dev"
}
},
"servers": [
{
"url": "https://api.firecrawl.dev/v0"
}
],
"paths": {
"/scrape": {
"post": {
"summary": "Scrape a single URL",
"operationId": "scrape",
"tags": ["Scraping"],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri",
"description": "The URL to scrape"
},
"formats": {
"type": "array",
"items": {
"type": "string",
"enum": [
"markdown",
"html",
"rawHtml",
"links",
"screenshot",
"screenshot@fullPage"
]
},
"description": "Specific formats to return.\n\n - markdown: The page in Markdown format.\n - html: The page's HTML, trimmed to include only meaningful content.\n - rawHtml: The page's original HTML.\n - links: The links on the page.\n - screenshot: A screenshot of the top of the page.\n - screenshot@fullPage: A screenshot of the full page. (overridden by screenshot if present)",
"default": ["markdown"]
},
"headers": {
"type": "object",
"description": "Headers to send with the request. Can be used to send cookies, user-agent, etc."
},
"includeTags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
},
"excludeTags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
},
"onlyMainContent": {
"type": "boolean",
"description": "Only return the main content of the page excluding headers, navs, footers, etc.",
"default": true
},
"timeout": {
"type": "integer",
"description": "Timeout in milliseconds for the request",
"default": 30000
},
"waitFor": {
"type": "integer",
"description": "Wait x amount of milliseconds for the page to load to fetch content",
"default": 0
}
},
"required": ["url"]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ScrapeResponse"
}
}
}
},
"402": {
"description": "Payment required",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Payment required to access this resource."
}
}
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Request rate limit exceeded. Please wait and try again later."
}
}
}
}
}
},
"500": {
"description": "Server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "An unexpected error occurred on the server."
}
}
}
}
}
}
}
}
},
"/crawl": {
"post": {
"summary": "Crawl multiple URLs based on options",
"operationId": "crawlUrls",
"tags": ["Crawling"],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri",
"description": "The base URL to start crawling from"
},
"crawlerOptions": {
"type": "object",
"properties": {
"includes": {
"type": "array",
"items": {
"type": "string"
},
"description": "URL patterns to include"
},
"excludes": {
"type": "array",
"items": {
"type": "string"
},
"description": "URL patterns to exclude"
},
"generateImgAltText": {
"type": "boolean",
"description": "Generate alt text for images using LLMs (must have a paid plan)",
"default": false
},
"returnOnlyUrls": {
"type": "boolean",
"description": "If true, returns only the URLs as a list on the crawl status. Attention: the return response will be a list of URLs inside the data, not a list of documents.",
"default": false
},
"maxDepth": {
"type": "integer",
"description": "Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern."
},
"mode": {
"type": "string",
"enum": ["default", "fast"],
"description": "The crawling mode to use. Fast mode crawls 4x faster websites without sitemap, but may not be as accurate and shouldn't be used in heavy js-rendered websites.",
"default": "default"
},
"ignoreSitemap": {
"type": "boolean",
"description": "Ignore the website sitemap when crawling",
"default": false
},
"limit": {
"type": "integer",
"description": "Maximum number of pages to crawl",
"default": 10000
},
"allowBackwardCrawling": {
"type": "boolean",
"description": "Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product'",
"default": false
},
"allowExternalContentLinks": {
"type": "boolean",
"description": "Allows the crawler to follow links to external websites.",
"default": false
}
}
},
"pageOptions": {
"type": "object",
"properties": {
"headers": {
"type": "object",
"description": "Headers to send with the request. Can be used to send cookies, user-agent, etc."
},
"includeHtml": {
"type": "boolean",
"description": "Include the HTML version of the content on page. Will output a html key in the response.",
"default": false
},
"includeRawHtml": {
"type": "boolean",
"description": "Include the raw HTML content of the page. Will output a rawHtml key in the response.",
"default": false
},
"onlyIncludeTags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
},
"onlyMainContent": {
"type": "boolean",
"description": "Only return the main content of the page excluding headers, navs, footers, etc.",
"default": false
},
"removeTags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
},
"replaceAllPathsWithAbsolutePaths": {
"type": "boolean",
"description": "Replace all relative paths with absolute paths for images and links",
"default": false
},
"screenshot": {
"type": "boolean",
"description": "Include a screenshot of the top of the page that you are scraping.",
"default": false
},
"fullPageScreenshot": {
"type": "boolean",
"description": "Include a full page screenshot of the page that you are scraping.",
"default": false
},
"waitFor": {
"type": "integer",
"description": "Wait x amount of milliseconds for the page to load to fetch content",
"default": 0
}
}
}
},
"required": ["url"]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CrawlResponse"
}
}
}
},
"402": {
"description": "Payment required",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Payment required to access this resource."
}
}
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Request rate limit exceeded. Please wait and try again later."
}
}
}
}
}
},
"500": {
"description": "Server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "An unexpected error occurred on the server."
}
}
}
}
}
}
}
}
},
"/search": {
"post": {
"summary": "Search for a keyword in Google, returns top page results with markdown content for each page",
"operationId": "searchGoogle",
"tags": ["Search"],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"format": "uri",
"description": "The query to search for"
},
"pageOptions": {
"type": "object",
"properties": {
"onlyMainContent": {
"type": "boolean",
"description": "Only return the main content of the page excluding headers, navs, footers, etc.",
"default": false
},
"fetchPageContent": {
"type": "boolean",
"description": "Fetch the content of each page. If false, defaults to a basic fast serp API.",
"default": true
},
"includeHtml": {
"type": "boolean",
"description": "Include the HTML version of the content on page. Will output a html key in the response.",
"default": false
},
"includeRawHtml": {
"type": "boolean",
"description": "Include the raw HTML content of the page. Will output a rawHtml key in the response.",
"default": false
}
}
},
"searchOptions": {
"type": "object",
"properties": {
"limit": {
"type": "integer",
"description": "Maximum number of results. Max is 20 during beta."
}
}
}
},
"required": ["query"]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SearchResponse"
}
}
}
},
"402": {
"description": "Payment required",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Payment required to access this resource."
}
}
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Request rate limit exceeded. Please wait and try again later."
}
}
}
}
}
},
"500": {
"description": "Server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "An unexpected error occurred on the server."
}
}
}
}
}
}
}
}
},
"/crawl/status/{jobId}": {
"get": {
"tags": ["Crawl"],
"summary": "Get the status of a crawl job",
"operationId": "getCrawlStatus",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "jobId",
"in": "path",
"description": "ID of the crawl job",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "Status of the job (completed, active, failed, paused)"
},
"current": {
"type": "integer",
"description": "Current page number"
},
"total": {
"type": "integer",
"description": "Total number of pages"
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CrawlStatusResponseObj"
},
"description": "Data returned from the job (null when it is in progress)"
},
"partial_data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CrawlStatusResponseObj"
},
"description": "Partial documents returned as it is being crawled (streaming). **This feature is currently in alpha - expect breaking changes** When a page is ready, it will append to the partial_data array, so there is no need to wait for the entire website to be crawled. When the crawl is done, partial_data will become empty and the result will be available in `data`. There is a max of 50 items in the array response. The oldest item (top of the array) will be removed when the new item is added to the array."
}
}
}
}
}
},
"402": {
"description": "Payment required",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Payment required to access this resource."
}
}
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Request rate limit exceeded. Please wait and try again later."
}
}
}
}
}
},
"500": {
"description": "Server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "An unexpected error occurred on the server."
}
}
}
}
}
}
}
}
},
"/crawl/cancel/{jobId}": {
"delete": {
"tags": ["Crawl"],
"summary": "Cancel a crawl job",
"operationId": "cancelCrawlJob",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "jobId",
"in": "path",
"description": "ID of the crawl job",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "Returns cancelled."
}
}
}
}
}
},
"402": {
"description": "Payment required",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Payment required to access this resource."
}
}
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "Request rate limit exceeded. Please wait and try again later."
}
}
}
}
}
},
"500": {
"description": "Server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "An unexpected error occurred on the server."
}
}
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer"
}
},
"schemas": {
"ScrapeResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"warning": {
"type": "string",
"nullable": true,
"description": "Warning message to let you know of any issues."
},
"data": {
"type": "object",
"properties": {
"markdown": {
"type": "string",
"nullable": true,
"description": "Markdown content of the page if the `markdown` format was specified (default)"
},
"html": {
"type": "string",
"nullable": true,
"description": "HTML version of the content on page if the `html` format was specified"
},
"rawHtml": {
"type": "string",
"nullable": true,
"description": "Raw HTML content of the page if the `rawHtml` format was specified"
},
"links": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
},
"nullable": true,
"description": "Links on the page if the `links` format was specified"
},
"screenshot": {
"type": "string",
"nullable": true,
"description": "URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified"
},
"metadata": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"language": {
"type": "string",
"nullable": true
},
"sourceURL": {
"type": "string",
"format": "uri"
},
"<any other metadata> ": {
"type": "string"
},
"statusCode": {
"type": "integer",
"description": "The status code of the page"
},
"error": {
"type": "string",
"nullable": true,
"description": "The error message of the page"
}
}
}
}
}
}
},
"CrawlStatusResponseObj": {
"type": "object",
"properties": {
"markdown": {
"type": "string",
"nullable": true,
"description": "Markdown content of the page if the `markdown` format was specified (default)"
},
"html": {
"type": "string",
"nullable": true,
"description": "HTML version of the content on page if the `html` format was specified"
},
"rawHtml": {
"type": "string",
"nullable": true,
"description": "Raw HTML content of the page if the `rawHtml` format was specified"
},
"links": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
},
"nullable": true,
"description": "Links on the page if the `links` format was specified"
},
"screenshot": {
"type": "string",
"nullable": true,
"description": "URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified"
},
"metadata": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"language": {
"type": "string",
"nullable": true
},
"sourceURL": {
"type": "string",
"format": "uri"
},
"<any other metadata> ": {
"type": "string"
},
"statusCode": {
"type": "integer",
"description": "The status code of the page"
},
"error": {
"type": "string",
"nullable": true,
"description": "The error message of the page"
}
}
}
}
},
"SearchResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"data": {
"type": "array",
"items": {
"markdown": {
"type": "string",
"nullable": true,
"description": "Markdown content of the page if the `markdown` format was specified (default)"
},
"html": {
"type": "string",
"nullable": true,
"description": "HTML version of the content on page if the `html` format was specified"
},
"rawHtml": {
"type": "string",
"nullable": true,
"description": "Raw HTML content of the page if the `rawHtml` format was specified"
},
"links": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
},
"nullable": true,
"description": "Links on the page if the `links` format was specified"
},
"screenshot": {
"type": "string",
"nullable": true,
"description": "URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified"
},
"metadata": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"language": {
"type": "string",
"nullable": true
},
"sourceURL": {
"type": "string",
"format": "uri"
},
"<any other metadata> ": {
"type": "string"
},
"statusCode": {
"type": "integer",
"description": "The status code of the page"
},
"error": {
"type": "string",
"nullable": true,
"description": "The error message of the page"
}
}
}
}
}
}
},
"CrawlResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"id": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
}
}
}
}
},
"security": [
{
"bearerAuth": []
}
]
}

Wyświetl plik

@ -0,0 +1,461 @@
openapi: 3.0.0
info:
title: Open-Meteo APIs
description: 'Open-Meteo offers free weather forecast APIs for open-source developers and non-commercial use. No API key is required.'
version: '1.0'
contact:
name: Open-Meteo
url: https://open-meteo.com
email: info@open-meteo.com
license:
name: Attribution 4.0 International (CC BY 4.0)
url: https://creativecommons.org/licenses/by/4.0/
termsOfService: https://open-meteo.com/en/features#terms
paths:
/v1/forecast:
servers:
- url: https://api.open-meteo.com
get:
tags:
- Weather Forecast APIs
summary: 7 day weather forecast for coordinates
description: 7 day weather variables in hourly and daily resolution for given WGS84 latitude and longitude coordinates. Available worldwide.
parameters:
- name: hourly
in: query
explode: false
schema:
type: array
items:
type: string
enum:
- temperature_2m
- relative_humidity_2m
- dew_point_2m
- apparent_temperature
- pressure_msl
- cloud_cover
- cloud_cover_low
- cloud_cover_mid
- cloud_cover_high
- wind_speed_10m
- wind_speed_80m
- wind_speed_120m
- wind_speed_180m
- wind_direction_10m
- wind_direction_80m
- wind_direction_120m
- wind_direction_180m
- wind_gusts_10m
- shortwave_radiation
- direct_radiation
- direct_normal_irradiance
- diffuse_radiation
- vapour_pressure_deficit
- evapotranspiration
- precipitation
- weather_code
- snow_height
- freezing_level_height
- soil_temperature_0cm
- soil_temperature_6cm
- soil_temperature_18cm
- soil_temperature_54cm
- soil_moisture_0_1cm
- soil_moisture_1_3cm
- soil_moisture_3_9cm
- soil_moisture_9_27cm
- soil_moisture_27_81cm
- name: daily
in: query
schema:
type: array
items:
type: string
enum:
- temperature_2m_max
- temperature_2m_min
- apparent_temperature_max
- apparent_temperature_min
- precipitation_sum
- precipitation_hours
- weather_code
- sunrise
- sunset
- wind_speed_10m_max
- wind_gusts_10m_max
- wind_direction_10m_dominant
- shortwave_radiation_sum
- uv_index_max
- uv_index_clear_sky_max
- et0_fao_evapotranspiration
- name: latitude
in: query
required: true
description: 'WGS84 coordinate'
schema:
type: number
format: double
- name: longitude
in: query
required: true
description: 'WGS84 coordinate'
schema:
type: number
format: double
- name: current_weather
in: query
schema:
type: boolean
- name: temperature_unit
in: query
schema:
type: string
default: celsius
enum:
- celsius
- fahrenheit
- name: wind_speed_unit
in: query
schema:
type: string
default: kmh
enum:
- kmh
- ms
- mph
- kn
- name: timeformat
in: query
description: If format `unixtime` is selected, all time values are returned in UNIX epoch time in seconds. Please not that all time is then in GMT+0! For daily values with unix timestamp, please apply `utc_offset_seconds` again to get the correct date.
schema:
type: string
default: iso8601
enum:
- iso8601
- unixtime
- name: timezone
in: query
description: If `timezone` is set, all timestamps are returned as local-time and data is returned starting at 0:00 local-time. Any time zone name from the [time zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is supported.
schema:
type: string
- name: past_days
in: query
description: If `past_days` is set, yesterdays or the day before yesterdays data are also returned.
schema:
type: integer
enum:
- 1
- 2
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
latitude:
type: number
example: 52.52
description: WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.
longitude:
type: number
example: 13.419.52
description: WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.
elevation:
type: number
example: 44.812
description: The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect.
generationtime_ms:
type: number
example: 2.2119
description: Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements.
utc_offset_seconds:
type: integer
example: 3600
description: Applied timezone offset from the &timezone= parameter.
hourly:
$ref: '#/components/schemas/HourlyResponse'
hourly_units:
type: object
additionalProperties:
type: string
description: For each selected weather variable, the unit will be listed here.
daily:
$ref: '#/components/schemas/DailyResponse'
daily_units:
type: object
additionalProperties:
type: string
description: For each selected daily weather variable, the unit will be listed here.
current_weather:
$ref: '#/components/schemas/CurrentWeather'
'400':
description: Bad Request
content:
application/json:
schema:
type: object
properties:
error:
type: boolean
description: Always set true for errors
reason:
type: string
description: Description of the error
example: 'Latitude must be in range of -90 to 90°. Given: 300'
components:
schemas:
HourlyResponse:
type: object
description: For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.
required:
- time
properties:
time:
type: array
items:
type: string
temperature_2m:
type: array
items:
type: number
relative_humidity_2m:
type: array
items:
type: number
dew_point_2m:
type: array
items:
type: number
apparent_temperature:
type: array
items:
type: number
pressure_msl:
type: array
items:
type: number
cloud_cover:
type: array
items:
type: number
cloud_cover_low:
type: array
items:
type: number
cloud_cover_mid:
type: array
items:
type: number
cloud_cover_high:
type: array
items:
type: number
wind_speed_10m:
type: array
items:
type: number
wind_speed_80m:
type: array
items:
type: number
wind_speed_120m:
type: array
items:
type: number
wind_speed_180m:
type: array
items:
type: number
wind_direction_10m:
type: array
items:
type: number
wind_direction_80m:
type: array
items:
type: number
wind_direction_120m:
type: array
items:
type: number
wind_direction_180m:
type: array
items:
type: number
wind_gusts_10m:
type: array
items:
type: number
shortwave_radiation:
type: array
items:
type: number
direct_radiation:
type: array
items:
type: number
direct_normal_irradiance:
type: array
items:
type: number
diffuse_radiation:
type: array
items:
type: number
vapour_pressure_deficit:
type: array
items:
type: number
evapotranspiration:
type: array
items:
type: number
precipitation:
type: array
items:
type: number
weather_code:
type: array
items:
type: number
snow_height:
type: array
items:
type: number
freezing_level_height:
type: array
items:
type: number
soil_temperature_0cm:
type: array
items:
type: number
soil_temperature_6cm:
type: array
items:
type: number
soil_temperature_18cm:
type: array
items:
type: number
soil_temperature_54cm:
type: array
items:
type: number
soil_moisture_0_1cm:
type: array
items:
type: number
soil_moisture_1_3cm:
type: array
items:
type: number
soil_moisture_3_9cm:
type: array
items:
type: number
soil_moisture_9_27cm:
type: array
items:
type: number
soil_moisture_27_81cm:
type: array
items:
type: number
DailyResponse:
type: object
description: For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.
properties:
time:
type: array
items:
type: string
temperature_2m_max:
type: array
items:
type: number
temperature_2m_min:
type: array
items:
type: number
apparent_temperature_max:
type: array
items:
type: number
apparent_temperature_min:
type: array
items:
type: number
precipitation_sum:
type: array
items:
type: number
precipitation_hours:
type: array
items:
type: number
weather_code:
type: array
items:
type: number
sunrise:
type: array
items:
type: number
sunset:
type: array
items:
type: number
wind_speed_10m_max:
type: array
items:
type: number
wind_gusts_10m_max:
type: array
items:
type: number
wind_direction_10m_dominant:
type: array
items:
type: number
shortwave_radiation_sum:
type: array
items:
type: number
uv_index_max:
type: array
items:
type: number
uv_index_clear_sky_max:
type: array
items:
type: number
et0_fao_evapotranspiration:
type: array
items:
type: number
required:
- time
CurrentWeather:
type: object
description: 'Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code'
properties:
time:
type: string
temperature:
type: number
wind_speed:
type: number
wind_direction:
type: number
weather_code:
type: integer
required:
- time
- temperature
- wind_speed
- wind_direction
- weather_code

Wyświetl plik

@ -0,0 +1,177 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": ["pets"],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"schema": {
"type": "integer",
"maximum": 100,
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "A paged array of pets",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pets"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": ["pets"],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": ["pets"],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to retrieve",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"type": "object",
"required": ["id", "name"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Pets": {
"type": "array",
"maxItems": 100,
"items": {
"$ref": "#/components/schemas/Pet"
}
},
"Error": {
"type": "object",
"required": ["code", "message"],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}

Wyświetl plik

@ -0,0 +1,235 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Swagger API Team",
"email": "apiteam@swagger.io",
"url": "http://swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/api"
}
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.",
"operationId": "findPets",
"parameters": [
{
"name": "tags",
"in": "query",
"description": "tags to filter by",
"required": false,
"style": "form",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
},
{
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"description": "Creates a new pet in the store. Duplicates are allowed",
"operationId": "addPet",
"requestBody": {
"description": "Pet to add to the store",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NewPet"
}
}
}
},
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/pets/{id}": {
"get": {
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
"operationId": "find pet by id",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to fetch",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"delete": {
"description": "deletes a single pet based on the ID supplied",
"operationId": "deletePet",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to delete",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"204": {
"description": "pet deleted"
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"allOf": [
{
"$ref": "#/components/schemas/NewPet"
},
{
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
}
}
]
},
"NewPet": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": ["code", "message"],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,392 @@
{
"openapi": "3.0.3",
"info": {
"version": "1.0.0",
"title": "Support for different security types",
"description": "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject"
},
"servers": [
{
"url": "https://httpbin.org"
}
],
"tags": [
{
"name": "API Key"
},
{
"name": "HTTP"
},
{
"name": "OAuth 2"
},
{
"name": "OpenID Connect"
},
{
"name": "Other"
}
],
"paths": {
"/anything/apiKey": {
"get": {
"summary": "Query parameter",
"description": "`apiKey` auth will be supplied within an `apiKey` query parameter.",
"tags": ["API Key"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"apiKey_query": []
}
]
},
"post": {
"summary": "Cookie",
"description": "`apiKey` auth will be supplied within an `api_key` cookie.",
"tags": ["API Key"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"apiKey_cookie": []
}
]
},
"put": {
"summary": "Header",
"description": "`apiKey` auth will be supplied within an `X-API-KEY` header.",
"tags": ["API Key"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"apiKey_header": []
}
]
}
},
"/anything/basic": {
"post": {
"summary": "Basic",
"description": "Authentication credentials will be supplied within a `Basic` `Authorization` header.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample",
"tags": ["HTTP"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"basic": []
}
]
}
},
"/anything/bearer": {
"post": {
"summary": "Bearer",
"description": "Authentication credentials will be supplied within a `Bearer` `Authorization` header.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample",
"tags": ["HTTP"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"bearer": []
}
]
},
"put": {
"summary": "Bearer (`jwt` format)",
"description": "Authentication credentials will be supplied within a `Bearer` `Authorization` header, but its data should be controlled as a JWT.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample\n\n> \n> We currently do not support any special handling for this so they're handled as a standard `Bearer` authentication token.",
"tags": ["HTTP"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"bearer_jwt": []
}
]
}
},
"/anything/oauth2": {
"post": {
"summary": "General support (all flow types)",
"description": "> \n> We currently do not handle OAuth 2 authentication flows so if an operation has an `oauth2` requirement we assume that the user, or the projects JWT, has a qualified `bearer` token and will use that.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"tags": ["OAuth 2"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"oauth2": ["write:things"]
}
]
},
"get": {
"summary": "General support (authorizationCode flow type)",
"description": "> \n> We currently do not handle OAuth 2 authentication flows so if an operation has an `oauth2` requirement we assume that the user, or the projects JWT, has a qualified `bearer` token and will use that.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"tags": ["OAuth 2"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"oauth2_authorizationCode": ["write:things"]
}
]
},
"put": {
"summary": "General support (clientCredentials flow type)",
"description": "> \n> We currently do not handle OAuth 2 authentication flows so if an operation has an `oauth2` requirement we assume that the user, or the projects JWT, has a qualified `bearer` token and will use that.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"tags": ["OAuth 2"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"oauth2_clientCredentials": ["write:things"]
}
]
},
"patch": {
"summary": "General support (implicit flow type)",
"description": "> \n> We currently do not handle OAuth 2 authentication flows so if an operation has an `oauth2` requirement we assume that the user, or the projects JWT, has a qualified `bearer` token and will use that.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"tags": ["OAuth 2"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"oauth2_implicit": ["write:things"]
}
]
},
"delete": {
"summary": "General support (password flow type)",
"description": "> \n> We currently do not handle OAuth 2 authentication flows so if an operation has an `oauth2` requirement we assume that the user, or the projects JWT, has a qualified `bearer` token and will use that.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"tags": ["OAuth 2"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"oauth2_password": ["write:things"]
}
]
}
},
"/anything/openIdConnect": {
"post": {
"summary": "General support",
"description": "🚧 This is not supported.",
"tags": ["OpenID Connect"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"openIdConnect": []
}
]
}
},
"/anything/no-auth": {
"post": {
"summary": "No auth requirements",
"description": "This operation does not have any authentication requirements.",
"tags": ["Other"],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/anything/optional-auth": {
"get": {
"summary": "Optional auth",
"description": "The `apiKey` query parameter auth on this operation is optional.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object",
"tags": ["Other"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"apiKey_query": []
},
{}
]
}
},
"/status/401": {
"post": {
"summary": "Forced invalid authentication",
"description": "This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.",
"tags": ["Other"],
"responses": {
"401": {
"description": "Unauthorized"
}
},
"security": [
{
"apiKey_header": []
}
]
}
}
},
"components": {
"securitySchemes": {
"apiKey_cookie": {
"type": "apiKey",
"in": "cookie",
"name": "api_key",
"description": "An API key that will be supplied in a named cookie. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object"
},
"apiKey_header": {
"type": "apiKey",
"in": "header",
"name": "X-API-KEY",
"description": "An API key that will be supplied in a named header. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object"
},
"apiKey_query": {
"type": "apiKey",
"in": "query",
"name": "apiKey",
"description": "An API key that will be supplied in a named query parameter. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object"
},
"basic": {
"type": "http",
"scheme": "basic",
"description": "Basic auth that takes a base64'd combination of `user:password`. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample"
},
"bearer": {
"type": "http",
"scheme": "bearer",
"description": "A bearer token that will be supplied within an `Authentication` header as `bearer <token>`. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample"
},
"bearer_jwt": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT",
"description": "A bearer token that will be supplied within an `Authentication` header as `bearer <token>`. In this case, the format of the token is specified as JWT. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#jwt-bearer-sample"
},
"oauth2": {
"type": "oauth2",
"description": "An OAuth 2 security flow. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23",
"flows": {
"authorizationCode": {
"authorizationUrl": "http://example.com/oauth/dialog",
"tokenUrl": "http://example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
},
"clientCredentials": {
"tokenUrl": "http://example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
},
"implicit": {
"authorizationUrl": "http://example.com/oauth/dialog",
"scopes": {
"write:things": "Add things to your account"
}
},
"password": {
"tokenUrl": "http://example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
}
}
},
"oauth2_authorizationCode": {
"type": "oauth2",
"description": "An OAuth 2 security flow that only supports the `authorizationCode` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flows-object",
"flows": {
"authorizationCode": {
"authorizationUrl": "http://alt.example.com/oauth/dialog",
"tokenUrl": "http://alt.example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
}
}
},
"oauth2_clientCredentials": {
"type": "oauth2",
"description": "An OAuth 2 security flow that only supports the `clientCredentials` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flows-object",
"flows": {
"clientCredentials": {
"tokenUrl": "http://alt.example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
}
}
},
"oauth2_implicit": {
"type": "oauth2",
"description": "An OAuth 2 security flow that only supports the `implicit` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flows-object",
"flows": {
"implicit": {
"authorizationUrl": "http://alt.example.com/oauth/dialog",
"scopes": {
"write:things": "Add things to your account"
}
}
}
},
"oauth2_password": {
"type": "oauth2",
"description": "An OAuth 2 security flow that only supports the `password` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flows-object",
"flows": {
"password": {
"tokenUrl": "http://alt.example.com/oauth/token",
"scopes": {
"write:things": "Add things to your account"
}
}
}
},
"openIdConnect": {
"type": "openIdConnect",
"openIdConnectUrl": "https://example.com/.well-known/openid-configuration",
"description": "OpenAPI authentication. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23"
}
}
}
}

Wyświetl plik

@ -0,0 +1,261 @@
{
"openapi": "3.1.0",
"info": {
"title": "Tic Tac Toe",
"description": "This API allows writing down marks on a Tic Tac Toe board\nand requesting the state of the board or of individual squares.\n",
"version": "1.0.0"
},
"tags": [
{
"name": "Gameplay"
}
],
"paths": {
"/board": {
"get": {
"summary": "Get the whole board",
"description": "Retrieves the current state of the board and the winner.",
"tags": ["Gameplay"],
"operationId": "get-board",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/status"
}
}
}
}
},
"security": [
{
"defaultApiKey": []
},
{
"app2AppOauth": ["board:read"]
}
]
}
},
"/board/{row}/{column}": {
"parameters": [
{
"$ref": "#/components/parameters/rowParam"
},
{
"$ref": "#/components/parameters/columnParam"
}
],
"get": {
"summary": "Get a single board square",
"description": "Retrieves the requested square.",
"tags": ["Gameplay"],
"operationId": "get-square",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/mark"
}
}
}
},
"400": {
"description": "The provided parameters are incorrect",
"content": {
"text/html": {
"schema": {
"$ref": "#/components/schemas/errorMessage"
},
"example": "Illegal coordinates"
}
}
}
},
"security": [
{
"bearerHttpAuthentication": []
},
{
"user2AppOauth": ["board:read"]
}
]
},
"put": {
"summary": "Set a single board square",
"description": "Places a mark on the board and retrieves the whole board and the winner (if any).",
"tags": ["Gameplay"],
"operationId": "put-square",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/mark"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/status"
}
}
}
},
"400": {
"description": "The provided parameters are incorrect",
"content": {
"text/html": {
"schema": {
"$ref": "#/components/schemas/errorMessage"
},
"examples": {
"illegalCoordinates": {
"value": "Illegal coordinates."
},
"notEmpty": {
"value": "Square is not empty."
},
"invalidMark": {
"value": "Invalid Mark (X or O)."
}
}
}
}
}
},
"security": [
{
"bearerHttpAuthentication": []
},
{
"user2AppOauth": ["board:write"]
}
]
}
}
},
"components": {
"parameters": {
"rowParam": {
"description": "Board row (vertical coordinate)",
"name": "row",
"in": "path",
"required": true,
"schema": {
"$ref": "#/components/schemas/coordinate"
}
},
"columnParam": {
"description": "Board column (horizontal coordinate)",
"name": "column",
"in": "path",
"required": true,
"schema": {
"$ref": "#/components/schemas/coordinate"
}
}
},
"schemas": {
"errorMessage": {
"type": "string",
"maxLength": 256,
"description": "A text message describing an error"
},
"coordinate": {
"type": "integer",
"minimum": 1,
"maximum": 3,
"example": 1
},
"mark": {
"type": "string",
"enum": [".", "X", "O"],
"description": "Possible values for a board square. `.` means empty square.",
"example": "."
},
"board": {
"type": "array",
"maxItems": 3,
"minItems": 3,
"items": {
"type": "array",
"maxItems": 3,
"minItems": 3,
"items": {
"$ref": "#/components/schemas/mark"
}
}
},
"winner": {
"type": "string",
"enum": [".", "X", "O"],
"description": "Winner of the game. `.` means nobody has won yet.",
"example": "."
},
"status": {
"type": "object",
"properties": {
"winner": {
"$ref": "#/components/schemas/winner"
},
"board": {
"$ref": "#/components/schemas/board"
}
}
}
},
"securitySchemes": {
"defaultApiKey": {
"description": "API key provided in console",
"type": "apiKey",
"name": "api-key",
"in": "header"
},
"basicHttpAuthentication": {
"description": "Basic HTTP Authentication",
"type": "http",
"scheme": "Basic"
},
"bearerHttpAuthentication": {
"description": "Bearer token using a JWT",
"type": "http",
"scheme": "Bearer",
"bearerFormat": "JWT"
},
"app2AppOauth": {
"type": "oauth2",
"flows": {
"clientCredentials": {
"tokenUrl": "https://learn.openapis.org/oauth/2.0/token",
"scopes": {
"board:read": "Read the board"
}
}
}
},
"user2AppOauth": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://learn.openapis.org/oauth/2.0/auth",
"tokenUrl": "https://learn.openapis.org/oauth/2.0/token",
"scopes": {
"board:read": "Read the board",
"board:write": "Write to the board"
}
}
}
}
}
}
}

Wyświetl plik

@ -0,0 +1,32 @@
{
"name": "@agentic/platform-openapi",
"version": "0.0.1",
"description": "OpenAPI utilities used by the Agentic platform.",
"author": "Travis Fischer <travis@transitivebullsh.it>",
"license": "UNLICENSED",
"repository": {
"type": "git",
"url": "git+https://github.com/transitive-bullshit/agentic-platform.git",
"directory": "packages/schemas"
},
"type": "module",
"source": "./src/index.ts",
"types": "./src/index.ts",
"sideEffects": false,
"exports": {
".": "./src/index.ts"
},
"scripts": {
"test": "run-s test:*",
"test:lint": "eslint .",
"test:typecheck": "tsc --noEmit",
"test:unit": "vitest run"
},
"dependencies": {
"@agentic/platform-core": "workspace:*",
"@redocly/openapi-core": "^1.34.3"
},
"publishConfig": {
"access": "public"
}
}

Wyświetl plik

@ -0,0 +1,2 @@
export type * from './types'
export * from './validate-openapi-spec'

Wyświetl plik

@ -0,0 +1,628 @@
export type Logger = Pick<Console, 'debug' | 'info' | 'warn' | 'error'>
// OpenAPI types are taken from https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/types.ts
// Note: these OpenAPI types are meant only for internal use, not external
// consumption. Some formatting may be better in other libraries meant for
// consumption. Some typing may be “loose” or “incorrect” in order to guarantee
// that all logical paths are handled. In other words, these are built more
// for ways schemas _can_ be written, not necessarily how they _should_ be.
export interface Extensible {
[key: `x-${string}`]: any
}
/**
* [4.8] Schema
* @see https://spec.openapis.org/oas/v3.1.0#schema
*/
export interface LooseOpenAPI3Spec extends Extensible {
/** REQUIRED. This string MUST be the version number of the OpenAPI Specification that the OpenAPI document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI document. This is not related to the API info.version string. */
openapi: string
/** REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. */
info: InfoObject // required
/** The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. */
jsonSchemaDialect?: string
/** An array of Server Objects, which provide connectivity information to a target server. If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /. */
servers?: ServerObject[]
/** The available paths and operations for the API. */
paths?: PathsObject
/** The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the callbacks feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An example is available. */
webhooks?: { [id: string]: PathItemObject | ReferenceObject }
/** An element to hold various schemas for the document. */
components?: ComponentsObject
/** A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement ({}) can be included in the array. */
security?: SecurityRequirementObject[]
/** A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the tools logic. Each tag name in the list MUST be unique. */
tags?: TagObject[]
/** Additional external documentation. */
externalDocs?: ExternalDocumentationObject
$defs?: $defs
}
/**
* [4.8.2] Info Object
* The object provides metadata about the API.
*/
export interface InfoObject extends Extensible {
/** REQUIRED. The title of the API. */
title: string
/** A short summary of the API. */
summary?: string
/** A description of the API. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
termsOfService?: string
/** The contact information for the exposed API. */
contact?: ContactObject
/** The license information for the exposed API. */
license?: LicenseObject
/** REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version). */
version: string
}
/**
* [4.8.3] Contact Object
* Contact information for the exposed API.
*/
export interface ContactObject extends Extensible {
/** The identifying name of the contact person/organization. */
name?: string
/** The URL pointing to the contact information. This MUST be in the form of a URL. */
url?: string
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
email?: string
}
/**
* [4.8.4] License object
* License information for the exposed API.
*/
export interface LicenseObject extends Extensible {
/** REQUIRED. The license name used for the API. */
name: string
/** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
identifier: string
/** A URL to the license used for the API. This MUST be in the form of a URL. The url field is mutually exclusive of the identifier field. */
url: string
}
/**
* [4.8.5] Server Object
* An object representing a Server.
*/
export interface ServerObject extends Extensible {
/** REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in {brackets}. */
url: string
/** An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. */
description: string
/** A map between a variable name and its value. The value is used for substitution in the servers URL template. */
variables: { [name: string]: ServerVariableObject }
}
/**
* [4.8.6] Server Variable Object
* An object representing a Server Variable for server URL template substitution.
*/
export interface ServerVariableObject extends Extensible {
/** An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty. */
enum?: string[]
/** REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. Note this behavior is different than the Schema Objects treatment of default values, because in those cases parameter values are optional. If the enum is defined, the value MUST exist in the enums values. */
default: string
/** An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. */
description?: string
}
/**
* [4.8.7] Components Object
* Holds a set of reusable objects for different aspects of the OAS.
*/
export interface ComponentsObject extends Extensible {
/** An object to hold reusable Schema Objects.*/
schemas?: Record<string, SchemaObject>
/** An object to hold reusable Response Objects. */
responses?: Record<string, ResponseObject | ReferenceObject>
/** An object to hold reusable Parameter Objects. */
parameters?: Record<string, ParameterObject | ReferenceObject>
/** An object to hold reusable Example Objects. */
examples?: Record<string, ExampleObject | ReferenceObject>
/** An object to hold reusable Request Body Objects. */
requestBodies?: Record<string, RequestBodyObject | ReferenceObject>
/** An object to hold reusable Header Objects. */
headers?: Record<string, HeaderObject | ReferenceObject>
/** An object to hold reusable Security Scheme Objects. */
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>
/** An object to hold reusable Link Objects. */
links?: Record<string, LinkObject | ReferenceObject>
/** An object to hold reusable Callback Objects. */
callbacks?: Record<string, CallbackObject | ReferenceObject>
/** An object to hold reusable Path Item Objects. */
pathItems?: Record<string, PathItemObject | ReferenceObject>
}
/**
* [4.8.8] Paths Object
* Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the Server Object in order to construct the full URL. The Paths MAY be empty, due to Access Control List (ACL) constraints.
*/
export interface PathsObject {
[pathname: string]: PathItemObject | ReferenceObject // note: paths object does support $refs; the schema just defines it in a weird way
}
/**
* [x.x.x] Webhooks Object
* Holds the webhooks definitions, indexed by their names. A webhook is defined by a Path Item Object; the only difference is that the request is initiated by the API provider.
*/
export interface WebhooksObject {
[name: string]: PathItemObject
}
/**
* [4.8.9] Path Item Object
* Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.
*/
export interface PathItemObject extends Extensible {
/** A definition of a GET operation on this path. */
get?: OperationObject | ReferenceObject
/** A definition of a PUT operation on this path. */
put?: OperationObject | ReferenceObject
/** A definition of a POST operation on this path. */
post?: OperationObject | ReferenceObject
/** A definition of a DELETE operation on this path. */
delete?: OperationObject | ReferenceObject
/** A definition of a OPTIONS operation on this path. */
options?: OperationObject | ReferenceObject
/** A definition of a HEAD operation on this path. */
head?: OperationObject | ReferenceObject
/** A definition of a PATCH operation on this path. */
patch?: OperationObject | ReferenceObject
/** A definition of a TRACE operation on this path. */
trace?: OperationObject | ReferenceObject
/** An alternative server array to service all operations in this path. */
servers?: ServerObject[]
/** A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the Reference Object to link to parameters that are defined at the OpenAPI Objects components/parameters. */
parameters?: (ParameterObject | ReferenceObject)[]
}
/**
* [4.8.10] Operation Object
* Describes a single API operation on a path.
*/
export interface OperationObject extends Extensible {
/** A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. */
tags?: string[]
/** A short summary of what the operation does. */
summary?: string
/** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** Additional external documentation for this operation. */
externalDocs?: ExternalDocumentationObject
/** Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. */
operationId?: string
/** A list of parameters that are applicable for this operation. If a parameter is already defined at the Path Item, the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the Reference Object to link to parameters that are defined at the OpenAPI Objects components/parameters. */
parameters?: (ParameterObject | ReferenceObject)[]
/** The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined semantics and SHOULD be avoided if possible. */
requestBody?: RequestBodyObject | ReferenceObject
/** The list of possible responses as they are returned from executing this operation. */
responses?: ResponsesObject
/** A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a Callback Object that describes a request that may be initiated by the API provider and the expected responses. */
callbacks?: Record<string, CallbackObject | ReferenceObject>
/** Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is false. */
deprecated?: boolean
/** A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. To make security optional, an empty security requirement ({}) can be included in the array. This definition overrides any declared top-level security. To remove a top-level security declaration, an empty array can be used. */
security?: SecurityRequirementObject[]
/** An alternative server array to service this operation. If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this value. */
servers?: ServerObject[]
}
/**
* [4.8.11] External Documentation Object
* Allows referencing an external resource for extended documentation.
*/
export interface ExternalDocumentationObject extends Extensible {
/** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
url: string
}
/**
* [4.8.12] Parameter Object
* Describes a single operation parameter.
* A unique parameter is defined by a combination of a name and location.
*/
export interface ParameterObject extends Extensible {
/**
* REQUIRED. The name of the parameter. Parameter names are case sensitive.
*
* - If `in` is `"path"`, the `name` field MUST correspond to a template expression occurring within the path field in the Paths Object. See Path Templating for further information.
* - If `in` is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.
* - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
*/
name: string
/** REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie".*/
in: 'query' | 'header' | 'path' | 'cookie'
/** A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false. */
required?: boolean
/** Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is false. */
deprecated?: boolean
/** Sets the ability to pass empty-valued parameters. This is valid only for query parameters and allows sending a parameter with an empty value. Default value is false. If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision. */
allowEmptyValue?: boolean
/** Describes 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. */
style?: string
/** When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When `style` is `form`, the default value is `true`. For all other styles, the default value is `false`. */
explode?: boolean
/** Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986] `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`. */
allowReserved?: boolean
/** The schema defining the type used for the parameter. */
schema?: SchemaObject
/** Example of the parameters potential value. */
example?: any
/** Examples of the parameters potential value. */
examples?: { [name: string]: ExampleObject | ReferenceObject }
/** A map containing the representations for the parameter. */
content?: { [contentType: string]: MediaTypeObject | ReferenceObject }
}
/**
* [4.8.13] Request Body Object
* Describes a single request body.
*/
export interface RequestBodyObject extends Extensible {
/** A brief description of the request body. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text */
content: { [contentType: string]: MediaTypeObject | ReferenceObject }
/** Determines if the request body is required in the request. Defaults to false. */
required?: boolean
}
/**
* [4.8.14] Media Type Object
*/
export interface MediaTypeObject extends Extensible {
/** The schema defining the content of the request, response, or parameter. */
schema?: SchemaObject | ReferenceObject
/** Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The example field is mutually exclusive of the examples field. Furthermore, if referencing a schema which contains an example, the example value SHALL override the example provided by the schema. */
example?: any
/** Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The examples field is mutually exclusive of the example field. Furthermore, if referencing a schema which contains an example, the examples value SHALL override the example provided by the schema. */
examples?: { [name: string]: ExampleObject | ReferenceObject }
/** A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded. */
encoding?: { [propertyName: string]: EncodingObject }
}
/**
* [4.8.15] Encoding Object
* A single encoding definition applied to a single schema property.
*/
export interface EncodingObject extends Extensible {
/** The Content-Type for encoding a specific property. Default value depends on the property type: for object - application/json; for array – the default is defined based on the inner type; for all other cases the default is application/octet-stream. The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the two types. */
contentType?: string
/** A map allowing additional information to be provided as headers, for example Content-Disposition. Content-Type is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a multipart. */
headers?: { [name: string]: HeaderObject | ReferenceObject }
/** Describes how a specific property value will be serialized depending on its type. See Parameter Object for details on the style property. The behavior follows the same values as query parameters, including default values. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored. */
style?: string
/** When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When style is form, the default value is true. For all other styles, the default value is false. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored. */
explode?: string
/** Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986] :/?#[]@!$&'()*+,;= to be included without percent-encoding. The default value is false. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored. */
allowReserved?: string
}
/**
* [4.8.16] Responses Object
* A container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
*/
export type ResponsesObject = {
[responseCode: string]: ResponseObject | ReferenceObject
} & {
/** The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. */
default?: ResponseObject | ReferenceObject
}
/**
* [4.8.17] Response Object
* Describes a single response from an API Operation, including design-time, static links to operations based on the response.
*/
export interface ResponseObject extends Extensible {
/** REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text representation. */
description: string
/** Maps a header name to its definition. [RFC7230] states header names are case insensitive. If a response header is defined with the name "Content-Type", it SHALL be ignored. */
headers?: { [name: string]: HeaderObject | ReferenceObject }
/** A map containing descriptions of potential response payloads. The key is a media type or media type range and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text */
content?: { [contentType: string]: MediaTypeObject }
/** A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. */
links?: { [name: string]: LinkObject | ReferenceObject }
}
/**
* [4.8.18] Callback Object
* A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.
*/
export type CallbackObject = Record<string, PathItemObject>
/**
* [4.8.19[ Example Object
*/
export interface ExampleObject extends Extensible {
/** Short description for the example. */
summary?: string
/** Long description for the example. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** Embedded literal example. The value field and externalValue field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. */
value?: any
/** A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The value field and externalValue field are mutually exclusive. See the rules for resolving Relative References. */
externalValue?: string
}
/**
* [4.8.20] Link Object
* The Link object represents a possible design-time link for a response. The presence of a link does not guarantee the callers ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.
*/
export interface LinkObject extends Extensible {
/** A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition. See the rules for resolving Relative References. */
operationRef?: string
/** The name of an existing, resolvable OAS operation, as defined with a unique operationId. This field is mutually exclusive of the operationRef field. */
operationId?: string
/** A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the parameter location [{in}.]{name} for operations that use the same parameter name in different locations (e.g. path.id). */
parameters?: { [name: string]: `$${string}` }
/** A literal value or {expression} to use as a request body when calling the target operation. */
requestBody?: `$${string}`
/** A description of the link. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** A server object to be used by the target operation. */
server?: ServerObject
}
/**
* [4.8.21] Header Object
* The Header Object follows the structure of the Parameter Object with the following changes:
*
* 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map.
* 2. `in` MUST NOT be specified, it is implicitly in `header`.
* 3. All traits that are affected by the location MUST be applicable to a location of `heade`r (for example, `style`).
*/
export type HeaderObject = Omit<ParameterObject, 'name' | 'in'>
/**
* [4.8.22] Tag Object
* Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.
*/
export interface TagObject extends Extensible {
/** REQUIRED. The name of the tag. */
name: string
/** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
description?: string
/** Additional external documentation for this tag. */
externalDocs?: ExternalDocumentationObject
}
/**
* [4.8.23] Reference Object
* A simple object to allow referencing other components in the OpenAPI document, internally and externally. The $ref string value contains a URI [RFC3986], which identifies the location of the value being referenced. See the rules for resolving Relative References.
*/
export interface ReferenceObject extends Extensible {
/** REQUIRED. The reference identifier. This MUST be in the form of a URI. */
$ref: string
/** A short summary which by default SHOULD override that of the referenced component. If the referenced object-type does not allow a summary field, then this field has no effect. */
summary?: string
/** A description which by default SHOULD override that of the referenced component. CommonMark syntax MAY be used for rich text representation. If the referenced object-type does not allow a description field, then this field has no effect. */
description?: string
}
/**
* [4.8.24] Schema Object
* The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the JSON Schema Specification Draft 2020-12.
*/
export type SchemaObject = {
/** The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the JSON Schema Specification Draft 2020-12. */
discriminator?: DiscriminatorObject
/** MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. */
xml?: XMLObject
/** Additional external documentation for this schema. */
externalDocs?: ExternalDocumentationObject
/** @deprecated */
example?: any
title?: string
description?: string
$comment?: string
deprecated?: boolean
readOnly?: boolean
writeOnly?: boolean
enum?: unknown[]
/** Use of this keyword is functionally equivalent to an "enum" (Section 6.1.2) with a single value. */
const?: unknown
default?: unknown
format?: string
/** @deprecated in 3.1 (still valid for 3.0) */
nullable?: boolean
oneOf?: (SchemaObject | ReferenceObject)[]
allOf?: (SchemaObject | ReferenceObject)[]
anyOf?: (SchemaObject | ReferenceObject)[]
required?: string[]
[key: `x-${string}`]: any
} & (
| StringSubtype
| NumberSubtype
| IntegerSubtype
| ArraySubtype
| BooleanSubtype
| NullSubtype
| ObjectSubtype
| {
type: (
| 'string'
| 'number'
| 'integer'
| 'array'
| 'boolean'
| 'null'
| 'object'
)[]
}
)
export interface StringSubtype {
type: 'string' | ['string', 'null']
enum?: (string | ReferenceObject)[]
}
export interface NumberSubtype {
type: 'number' | ['number', 'null']
minimum?: number
maximum?: number
enum?: (number | ReferenceObject)[]
}
export interface IntegerSubtype {
type: 'integer' | ['integer', 'null']
minimum?: number
maximum?: number
enum?: (number | ReferenceObject)[]
}
export interface ArraySubtype {
type: 'array' | ['array', 'null']
prefixItems?: (SchemaObject | ReferenceObject)[]
items?: SchemaObject | ReferenceObject | (SchemaObject | ReferenceObject)[]
minItems?: number
maxItems?: number
enum?: (SchemaObject | ReferenceObject)[]
}
export interface BooleanSubtype {
type: 'boolean' | ['boolean', 'null']
enum?: (boolean | ReferenceObject)[]
}
export interface NullSubtype {
type: 'null'
}
export interface ObjectSubtype {
type: 'object' | ['object', 'null']
properties?: { [name: string]: SchemaObject | ReferenceObject }
additionalProperties?:
| boolean
| Record<string, never>
| SchemaObject
| ReferenceObject
required?: string[]
allOf?: (SchemaObject | ReferenceObject)[]
anyOf?: (SchemaObject | ReferenceObject)[]
enum?: (SchemaObject | ReferenceObject)[]
$defs?: $defs
}
/**
* [4.8.25] Discriminator Object
* When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the document of an alternative schema based on the value associated with it.
*/
export interface DiscriminatorObject {
/** REQUIRED. The name of the property in the payload that will hold the discriminator value. */
propertyName: string
/** An object to hold mappings between payload values and schema names or references. */
mapping?: Record<string, string>
/** If this exists, then a discriminator type should be added to objects matching this path */
oneOf?: string[]
}
/**
* [4.8.26] XML Object
* A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are not inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior.
*/
export interface XMLObject extends Extensible {
/** Replaces the name of the element/attribute used for the described schema property. When defined within `items`, it will affect the name of the individual XML elements within the list. When defined alongside `type` being `array` (outside the `items`), it will affect the wrapping element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored. */
name?: string
/** The URI of the namespace definition. This MUST be in the form of an absolute URI. */
namespace?: string
/** The prefix to be used for the name. */
prefix?: string
/** Declares whether the property definition translates to an attribute instead of an element. Default value is `false`. */
attribute?: boolean
/** MAY be used only for an array definition. Signifies whether the array is wrapped (for example, `<books><book/><book/></books>`) or unwrapped (`<book/><book/>`). Default value is `false`. The definition takes effect only when defined alongside `type` being `array` (outside the `items`). */
wrapped?: boolean
}
/**
* [4.8.27] Security Scheme Object
* Defines a security scheme that can be used by the operations.
*/
export type SecuritySchemeObject = {
/** A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
description?: string
[key: `x-${string}`]: any
} & (
| {
/** REQUIRED. The type of the security scheme. */
type: 'apiKey'
/** REQUIRED. The name of the header, query or cookie parameter to be used. */
name: string
/** REQUIRED. The location of the API key. */
in: 'query' | 'header' | 'cookie'
}
| {
/** REQUIRED. The type of the security scheme. */
type: 'http'
/** REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry. */
scheme: string
/** A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. */
bearer?: string
}
| {
/** REQUIRED. The type of the security scheme. */
type: 'mutualTLS'
}
| {
/** REQUIRED. Tye type of the security scheme. */
type: 'oauth2'
/** REQUIRED. An object containing configuration information for the flow types supported. */
flows: OAuthFlowsObject
}
| {
/** REQUIRED. Tye type of the security scheme. */
type: 'openIdConnect'
/** REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. The OpenID Connect standard requires the use of TLS. */
openIdConnectUrl: string
}
)
/**
* [4.8.26] OAuth Flows Object
* Allows configuration of the supported OAuth Flows.
*/
export interface OAuthFlowsObject extends Extensible {
/** Configuration for the OAuth Implicit flow */
implicit?: OAuthFlowObject
/** Configuration for the OAuth Resource Owner Password flow */
password?: OAuthFlowObject
/** Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. */
clientCredentials?: OAuthFlowObject
/** Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. */
authorizationCode?: OAuthFlowObject
}
/**
* [4.8.29] OAuth Flow Object
* Configuration details for a supported OAuth Flow
*/
export interface OAuthFlowObject extends Extensible {
/** REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
authorizationUrl: string
/** REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
tokenUrl: string
/** The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
refreshUrl: string
/** REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty. */
scopes: { [name: string]: string }
}
/**
* [4.8.30] Security Requirements Object
* Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.
*/
export type SecurityRequirementObject = {
[P in keyof ComponentsObject['securitySchemes']]?: string[]
}
export type $defs = Record<string, SchemaObject>

Wyświetl plik

@ -0,0 +1,40 @@
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, test } from 'vitest'
import { validateOpenAPISpec } from './validate-openapi-spec'
const fixtures = [
'basic.json',
'firecrawl.json',
'github.json',
'notion.json',
// 'open-meteo.yaml', // TODO
'pet-store.json',
'petstore-expanded.json',
'security.json',
'stripe.json',
'tic-tac-toe.json'
]
const dirname = path.join(fileURLToPath(import.meta.url), '..', '..')
describe('validateOpenAPISpec', () => {
for (const fixture of fixtures) {
test(
fixture,
{
timeout: 60_000
},
async () => {
const fixturePath = path.join(dirname, 'fixtures', fixture)
const spec = await readFile(fixturePath, 'utf8')
const result = await validateOpenAPISpec(spec)
expect(result).toMatchSnapshot()
}
)
}
})

Wyświetl plik

@ -10,8 +10,7 @@ import {
Source
} from '@redocly/openapi-core'
import type { Logger } from './logger'
import type { LooseOpenAPI3Spec } from './types'
import type { Logger, LooseOpenAPI3Spec } from './types'
/**
* Validates an OpenAPI spec and bundles it into a single, normalized schema.
@ -23,14 +22,14 @@ import type { LooseOpenAPI3Spec } from './types'
export async function validateOpenAPISpec(
source: string,
{
logger,
redoclyConfig,
logger = console,
silent = false
}: {
logger: Logger
redoclyConfig?: RedoclyConfig
logger?: Logger
silent?: boolean
}
} = {}
): Promise<LooseOpenAPI3Spec> {
if (!redoclyConfig) {
redoclyConfig = await createConfig(
@ -44,7 +43,6 @@ export async function validateOpenAPISpec(
)
}
logger.debug('Parsing openapi spec')
const resolver = new BaseResolver(redoclyConfig.resolve)
let parsed: any
@ -58,7 +56,6 @@ export async function validateOpenAPISpec(
source: new Source('', source, 'application/json'),
parsed
}
logger.debug('Parsed openapi spec')
// Check for OpenAPI 3 or greater
const openapiVersion = Number.parseFloat(document.parsed.openapi)
@ -82,23 +79,19 @@ export async function validateOpenAPISpec(
throw new Error('Unsupported schema format, expected `openapi: 3.x`')
}
logger.debug('>>> Linting openapi spec')
const problems = await lintDocument({
document,
config: redoclyConfig.styleguide,
externalRefResolver: resolver
})
_processProblems(problems, { silent, logger })
logger.debug('<<< Linting openapi spec')
logger.debug('>>> Bundling openapi spec')
const bundled = await bundle({
config: redoclyConfig,
dereference: false,
doc: document
})
_processProblems(bundled.problems, { silent, logger })
logger.debug('<<< Bundling openapi spec')
return bundled.bundle.parsed
}

Wyświetl plik

@ -0,0 +1,5 @@
{
"extends": "@fisch0920/config/tsconfig-node",
"include": ["src", "*.config.ts", "bin/*"],
"exclude": ["node_modules"]
}

Wyświetl plik

@ -131,6 +131,9 @@ importers:
'@agentic/platform-core':
specifier: workspace:*
version: link:../../packages/core
'@agentic/platform-openapi':
specifier: workspace:*
version: link:../../packages/openapi
'@agentic/platform-schemas':
specifier: workspace:*
version: link:../../packages/schemas
@ -158,9 +161,6 @@ importers:
'@paralleldrive/cuid2':
specifier: ^2.2.2
version: 2.2.2
'@redocly/openapi-core':
specifier: ^1.34.3
version: 1.34.3(supports-color@10.0.0)
'@sentry/node':
specifier: ^9.19.0
version: 9.19.0
@ -207,9 +207,6 @@ importers:
drizzle-orm:
specifier: ^0.43.1
version: 0.43.1(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(kysely@0.28.2)(postgres@3.4.5)
openapi-typescript:
specifier: ^7.8.0
version: 7.8.0(typescript@5.8.3)
packages/api-client:
dependencies:
@ -307,6 +304,15 @@ importers:
specifier: ^4.7.9
version: 4.7.9
packages/openapi:
dependencies:
'@agentic/platform-core':
specifier: workspace:*
version: link:../core
'@redocly/openapi-core':
specifier: ^1.34.3
version: 1.34.3(supports-color@10.0.0)
packages/schemas:
dependencies:
'@agentic/platform-core':