feat: add integration tests to openapi-to-ts

pull/701/head
Travis Fischer 2025-03-25 19:26:15 +08:00
rodzic f867fa812e
commit 0ea3ee6d7d
22 zmienionych plików z 16955 dodań i 12119 usunięć

Wyświetl plik

@ -5,7 +5,13 @@
* This file was auto-generated from an OpenAPI spec.
*/
import { aiFunction, AIFunctionsProvider, assert, getEnv } from '@agentic/core'
import {
aiFunction,
AIFunctionsProvider,
assert,
getEnv,
pick
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
@ -21,7 +27,6 @@ export namespace firecrawl {
/** Warning message to let you know of any issues. */
warning: z
.string()
.nullable()
.describe('Warning message to let you know of any issues.')
.optional(),
data: z
@ -29,7 +34,6 @@ export namespace firecrawl {
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.nullable()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
@ -37,7 +41,6 @@ export namespace firecrawl {
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.nullable()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
@ -45,7 +48,6 @@ export namespace firecrawl {
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.nullable()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
@ -53,13 +55,11 @@ export namespace firecrawl {
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.nullable()
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.nullable()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
@ -68,7 +68,7 @@ export namespace firecrawl {
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().nullable().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
@ -80,7 +80,6 @@ export namespace firecrawl {
/** The error message of the page */
error: z
.string()
.nullable()
.describe('The error message of the page')
.optional()
})
@ -107,7 +106,6 @@ export namespace firecrawl {
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.nullable()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
@ -115,7 +113,6 @@ export namespace firecrawl {
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.nullable()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
@ -123,7 +120,6 @@ export namespace firecrawl {
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.nullable()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
@ -131,13 +127,11 @@ export namespace firecrawl {
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.nullable()
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.nullable()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
@ -146,7 +140,7 @@ export namespace firecrawl {
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().nullable().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
@ -156,11 +150,7 @@ export namespace firecrawl {
.describe('The status code of the page')
.optional(),
/** The error message of the page */
error: z
.string()
.nullable()
.describe('The error message of the page')
.optional()
error: z.string().describe('The error message of the page').optional()
})
.optional()
})
@ -535,7 +525,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'scrape',
description: 'Scrape a single URL.',
description: `Scrape a single URL.`,
inputSchema: firecrawl.ScrapeParamsSchema
})
async scrape(
@ -543,7 +533,17 @@ export class FirecrawlClient extends AIFunctionsProvider {
): Promise<firecrawl.ScrapeResponse> {
return this.ky
.post('/scrape', {
json: params
json: pick(
params,
'url',
'formats',
'headers',
'includeTags',
'excludeTags',
'onlyMainContent',
'timeout',
'waitFor'
)
})
.json<firecrawl.ScrapeResponse>()
}
@ -553,7 +553,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'crawl_urls',
description: 'Crawl multiple URLs based on options.',
description: `Crawl multiple URLs based on options.`,
inputSchema: firecrawl.CrawlUrlsParamsSchema
})
async crawlUrls(
@ -561,7 +561,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
): Promise<firecrawl.CrawlUrlsResponse> {
return this.ky
.post('/crawl', {
json: params
json: pick(params, 'url', 'crawlerOptions', 'pageOptions')
})
.json<firecrawl.CrawlUrlsResponse>()
}
@ -571,8 +571,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'search_google',
description:
'Search for a keyword in Google, returns top page results with markdown content for each page.',
description: `Search for a keyword in Google, returns top page results with markdown content for each page.`,
inputSchema: firecrawl.SearchGoogleParamsSchema
})
async searchGoogle(
@ -580,7 +579,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
): Promise<firecrawl.SearchGoogleResponse> {
return this.ky
.post('/search', {
json: params
json: pick(params, 'query', 'pageOptions', 'searchOptions')
})
.json<firecrawl.SearchGoogleResponse>()
}
@ -590,7 +589,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_crawl_status',
description: 'Get the status of a crawl job.',
description: `Get the status of a crawl job.`,
inputSchema: firecrawl.GetCrawlStatusParamsSchema
})
async getCrawlStatus(
@ -606,7 +605,7 @@ export class FirecrawlClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'cancel_crawl_job',
description: 'Cancel a crawl job.',
description: `Cancel a crawl job.`,
inputSchema: firecrawl.CancelCrawlJobParamsSchema
})
async cancelCrawlJob(

Wyświetl plik

@ -1506,7 +1506,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_self',
description: 'Get current user.',
description: `Get current user.`,
inputSchema: notion.GetSelfParamsSchema
})
async getSelf(
@ -1520,7 +1520,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_user',
description: 'Get user.',
description: `Get user.`,
inputSchema: notion.GetUserParamsSchema
})
async getUser(params: notion.GetUserParams): Promise<notion.GetUserResponse> {
@ -1534,7 +1534,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'list_users',
description: 'List users.',
description: `List users.`,
inputSchema: notion.ListUsersParamsSchema
})
async listUsers(
@ -1542,7 +1542,9 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.ListUsersResponse> {
return this.ky
.get('/users', {
searchParams: sanitizeSearchParams(params)
searchParams: sanitizeSearchParams(
pick(params, 'start_cursor', 'page_size')
)
})
.json<notion.ListUsersResponse>()
}
@ -1552,7 +1554,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'create_page',
description: 'Create page.',
description: `Create page.`,
inputSchema: notion.CreatePageParamsSchema
})
async createPage(
@ -1560,7 +1562,7 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.CreatePageResponse> {
return this.ky
.post('/pages', {
json: params
json: pick(params, 'parent', 'properties')
})
.json<notion.CreatePageResponse>()
}
@ -1570,7 +1572,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_page',
description: 'Get page.',
description: `Get page.`,
inputSchema: notion.GetPageParamsSchema
})
async getPage(params: notion.GetPageParams): Promise<notion.GetPageResponse> {
@ -1586,7 +1588,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'update_page',
description: 'Update page.',
description: `Update page.`,
inputSchema: notion.UpdatePageParamsSchema
})
async updatePage(
@ -1604,7 +1606,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_page_property',
description: 'Get page property.',
description: `Get page property.`,
inputSchema: notion.GetPagePropertyParamsSchema
})
async getPageProperty(
@ -1624,7 +1626,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_block',
description: 'Get block.',
description: `Get block.`,
inputSchema: notion.GetBlockParamsSchema
})
async getBlock(
@ -1640,7 +1642,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'delete_block',
description: 'Delete block.',
description: `Delete block.`,
inputSchema: notion.DeleteBlockParamsSchema
})
async deleteBlock(
@ -1656,7 +1658,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'update_block',
description: 'Update block.',
description: `Update block.`,
inputSchema: notion.UpdateBlockParamsSchema
})
async updateBlock(
@ -1701,7 +1703,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'list_block_children',
description: 'List block children.',
description: `List block children.`,
inputSchema: notion.ListBlockChildrenParamsSchema
})
async listBlockChildren(
@ -1721,7 +1723,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'append_block_children',
description: 'Append block children.',
description: `Append block children.`,
inputSchema: notion.AppendBlockChildrenParamsSchema
})
async appendBlockChildren(
@ -1739,7 +1741,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'get_database',
description: 'Get database.',
description: `Get database.`,
inputSchema: notion.GetDatabaseParamsSchema
})
async getDatabase(
@ -1755,7 +1757,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'update_database',
description: 'Update database.',
description: `Update database.`,
inputSchema: notion.UpdateDatabaseParamsSchema
})
async updateDatabase(
@ -1782,7 +1784,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'query_database',
description: 'Query database.',
description: `Query database.`,
inputSchema: notion.QueryDatabaseParamsSchema
})
async queryDatabase(
@ -1808,7 +1810,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'list_databases',
description: 'List databases.',
description: `List databases.`,
inputSchema: notion.ListDatabasesParamsSchema
})
async listDatabases(
@ -1816,7 +1818,9 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.ListDatabasesResponse> {
return this.ky
.get('/databases', {
searchParams: sanitizeSearchParams(params)
searchParams: sanitizeSearchParams(
pick(params, 'start_cursor', 'page_size')
)
})
.json<notion.ListDatabasesResponse>()
}
@ -1826,7 +1830,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'create_database',
description: 'Create database.',
description: `Create database.`,
inputSchema: notion.CreateDatabaseParamsSchema
})
async createDatabase(
@ -1834,7 +1838,16 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.CreateDatabaseResponse> {
return this.ky
.post('/databases', {
json: params
json: pick(
params,
'parent',
'properties',
'icon',
'cover',
'title',
'description',
'is_inline'
)
})
.json<notion.CreateDatabaseResponse>()
}
@ -1844,13 +1857,20 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'search',
description: 'Search.',
description: `Search.`,
inputSchema: notion.SearchParamsSchema
})
async search(params: notion.SearchParams): Promise<notion.SearchResponse> {
return this.ky
.post('/search', {
json: params
json: pick(
params,
'query',
'sort',
'filter',
'start_cursor',
'page_size'
)
})
.json<notion.SearchResponse>()
}
@ -1860,7 +1880,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'list_comments',
description: 'List comments.',
description: `List comments.`,
inputSchema: notion.ListCommentsParamsSchema
})
async listComments(
@ -1868,7 +1888,9 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.ListCommentsResponse> {
return this.ky
.get('/comments', {
searchParams: sanitizeSearchParams(params)
searchParams: sanitizeSearchParams(
pick(params, 'block_id', 'start_cursor', 'page_size')
)
})
.json<notion.ListCommentsResponse>()
}
@ -1878,7 +1900,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'create_comment',
description: 'Create comment.',
description: `Create comment.`,
// TODO: Improve handling of union params
inputSchema: notion.CreateCommentParamsSchema as any
})
@ -1897,7 +1919,7 @@ export class NotionClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'oauth_token',
description: 'OAuth token.',
description: `OAuth token.`,
inputSchema: notion.OauthTokenParamsSchema
})
async oauthToken(
@ -1905,7 +1927,13 @@ export class NotionClient extends AIFunctionsProvider {
): Promise<notion.OauthTokenResponse> {
return this.ky
.post('/oauth/token', {
json: params
json: pick(
params,
'grant_type',
'code',
'redirect_uri',
'external_account'
)
})
.json<notion.OauthTokenResponse>()
}

Wyświetl plik

@ -8,6 +8,7 @@
import {
aiFunction,
AIFunctionsProvider,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
@ -93,7 +94,7 @@ export class PetStoreClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'list_pets',
description: 'List all pets.',
description: `List all pets.`,
inputSchema: petstore.ListPetsParamsSchema
})
async listPets(
@ -111,7 +112,7 @@ export class PetStoreClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'create_pets',
description: 'Create a pet.',
description: `Create a pet.`,
inputSchema: petstore.CreatePetsParamsSchema
})
async createPets(
@ -119,7 +120,7 @@ export class PetStoreClient extends AIFunctionsProvider {
): Promise<petstore.CreatePetsResponse> {
return this.ky
.post('/pets', {
json: params
json: pick(params, 'id', 'name', 'tag')
})
.json<petstore.CreatePetsResponse>()
}
@ -129,7 +130,7 @@ export class PetStoreClient extends AIFunctionsProvider {
*/
@aiFunction({
name: 'show_pet_by_id',
description: 'Info for a specific pet.',
description: `Info for a specific pet.`,
inputSchema: petstore.ShowPetByIdParamsSchema
})
async showPetById(

Wyświetl plik

@ -0,0 +1,179 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
aiFunction,
AIFunctionsProvider,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace petstoreexpanded {
export const apiBaseUrl = 'http://petstore.swagger.io/api'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const NewPetSchema = z.object({
name: z.string(),
tag: z.string().optional()
})
export type NewPet = z.infer<typeof NewPetSchema>
export const PetSchema = z.intersection(
NewPetSchema,
z.object({ id: z.number().int() })
)
export type Pet = z.infer<typeof PetSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const FindPetsParamsSchema = z.object({
/** tags to filter by */
tags: z.array(z.string()).describe('tags to filter by').optional(),
/** maximum number of results to return */
limit: z
.number()
.int()
.describe('maximum number of results to return')
.optional()
})
export type FindPetsParams = z.infer<typeof FindPetsParamsSchema>
export const FindPetsResponseSchema = z.array(PetSchema)
export type FindPetsResponse = z.infer<typeof FindPetsResponseSchema>
export const AddPetParamsSchema = NewPetSchema
export type AddPetParams = z.infer<typeof AddPetParamsSchema>
export const AddPetResponseSchema = PetSchema
export type AddPetResponse = z.infer<typeof AddPetResponseSchema>
export const FindPetByIdParamsSchema = z.object({
/** ID of pet to fetch */
id: z.number().int().describe('ID of pet to fetch')
})
export type FindPetByIdParams = z.infer<typeof FindPetByIdParamsSchema>
export const FindPetByIdResponseSchema = PetSchema
export type FindPetByIdResponse = z.infer<typeof FindPetByIdResponseSchema>
export const DeletePetParamsSchema = z.object({
/** ID of pet to delete */
id: z.number().int().describe('ID of pet to delete')
})
export type DeletePetParams = z.infer<typeof DeletePetParamsSchema>
export type DeletePetResponse = undefined
}
/**
* Agentic PetstoreExpanded client.
*
* A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification.
*/
export class PetstoreExpandedClient extends AIFunctionsProvider {
protected readonly ky: KyInstance
protected readonly apiBaseUrl: string
constructor({
apiBaseUrl = petstoreexpanded.apiBaseUrl,
ky = defaultKy
}: {
apiKey?: string
apiBaseUrl?: string
ky?: KyInstance
} = {}) {
super()
this.apiBaseUrl = apiBaseUrl
this.ky = ky.extend({
prefixUrl: apiBaseUrl
})
}
/**
* Returns all pets from the system that the user has access to
Nam 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.
Sed 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.
*/
@aiFunction({
name: 'find_pets',
description: `Returns all pets from the system that the user has access to
Nam 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.
Sed 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.`,
inputSchema: petstoreexpanded.FindPetsParamsSchema
})
async findPets(
params: petstoreexpanded.FindPetsParams
): Promise<petstoreexpanded.FindPetsResponse> {
return this.ky
.get('/pets', {
searchParams: sanitizeSearchParams(pick(params, 'tags', 'limit'))
})
.json<petstoreexpanded.FindPetsResponse>()
}
/**
* Creates a new pet in the store. Duplicates are allowed.
*/
@aiFunction({
name: 'add_pet',
description: `Creates a new pet in the store. Duplicates are allowed.`,
inputSchema: petstoreexpanded.AddPetParamsSchema
})
async addPet(
params: petstoreexpanded.AddPetParams
): Promise<petstoreexpanded.AddPetResponse> {
return this.ky
.post('/pets', {
json: pick(params, 'name', 'tag')
})
.json<petstoreexpanded.AddPetResponse>()
}
/**
* Returns a user based on a single ID, if the user does not have access to the pet.
*/
@aiFunction({
name: 'find_pet_by_id',
description: `Returns a user based on a single ID, if the user does not have access to the pet.`,
inputSchema: petstoreexpanded.FindPetByIdParamsSchema
})
async findPetById(
params: petstoreexpanded.FindPetByIdParams
): Promise<petstoreexpanded.FindPetByIdResponse> {
return this.ky
.get(`/pets/${params.id}`)
.json<petstoreexpanded.FindPetByIdResponse>()
}
/**
* deletes a single pet based on the ID supplied.
*/
@aiFunction({
name: 'delete_pet',
description: `deletes a single pet based on the ID supplied.`,
inputSchema: petstoreexpanded.DeletePetParamsSchema
})
async deletePet(
params: petstoreexpanded.DeletePetParams
): Promise<petstoreexpanded.DeletePetResponse> {
return this.ky
.delete(`/pets/${params.id}`)
.json<petstoreexpanded.DeletePetResponse>()
}
}

Wyświetl plik

@ -0,0 +1,439 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace security {
export const apiBaseUrl = 'https://httpbin.org'
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetAnythingApiKeyParamsSchema = z.object({})
export type GetAnythingApiKeyParams = z.infer<
typeof GetAnythingApiKeyParamsSchema
>
export type GetAnythingApiKeyResponse = undefined
export const PostAnythingApiKeyParamsSchema = z.object({})
export type PostAnythingApiKeyParams = z.infer<
typeof PostAnythingApiKeyParamsSchema
>
export type PostAnythingApiKeyResponse = undefined
export const PutAnythingApiKeyParamsSchema = z.object({})
export type PutAnythingApiKeyParams = z.infer<
typeof PutAnythingApiKeyParamsSchema
>
export type PutAnythingApiKeyResponse = undefined
export const PostAnythingBasicParamsSchema = z.object({})
export type PostAnythingBasicParams = z.infer<
typeof PostAnythingBasicParamsSchema
>
export type PostAnythingBasicResponse = undefined
export const PostAnythingBearerParamsSchema = z.object({})
export type PostAnythingBearerParams = z.infer<
typeof PostAnythingBearerParamsSchema
>
export type PostAnythingBearerResponse = undefined
export const PutAnythingBearerParamsSchema = z.object({})
export type PutAnythingBearerParams = z.infer<
typeof PutAnythingBearerParamsSchema
>
export type PutAnythingBearerResponse = undefined
export const GetAnythingOauth2ParamsSchema = z.object({})
export type GetAnythingOauth2Params = z.infer<
typeof GetAnythingOauth2ParamsSchema
>
export type GetAnythingOauth2Response = undefined
export const PostAnythingOauth2ParamsSchema = z.object({})
export type PostAnythingOauth2Params = z.infer<
typeof PostAnythingOauth2ParamsSchema
>
export type PostAnythingOauth2Response = undefined
export const PutAnythingOauth2ParamsSchema = z.object({})
export type PutAnythingOauth2Params = z.infer<
typeof PutAnythingOauth2ParamsSchema
>
export type PutAnythingOauth2Response = undefined
export const DeleteAnythingOauth2ParamsSchema = z.object({})
export type DeleteAnythingOauth2Params = z.infer<
typeof DeleteAnythingOauth2ParamsSchema
>
export type DeleteAnythingOauth2Response = undefined
export const PatchAnythingOauth2ParamsSchema = z.object({})
export type PatchAnythingOauth2Params = z.infer<
typeof PatchAnythingOauth2ParamsSchema
>
export type PatchAnythingOauth2Response = undefined
export const PostAnythingOpenIdConnectParamsSchema = z.object({})
export type PostAnythingOpenIdConnectParams = z.infer<
typeof PostAnythingOpenIdConnectParamsSchema
>
export type PostAnythingOpenIdConnectResponse = undefined
export const PostAnythingNoAuthParamsSchema = z.object({})
export type PostAnythingNoAuthParams = z.infer<
typeof PostAnythingNoAuthParamsSchema
>
export type PostAnythingNoAuthResponse = undefined
export const GetAnythingOptionalAuthParamsSchema = z.object({})
export type GetAnythingOptionalAuthParams = z.infer<
typeof GetAnythingOptionalAuthParamsSchema
>
export type GetAnythingOptionalAuthResponse = undefined
export const PostStatus401ParamsSchema = z.object({})
export type PostStatus401Params = z.infer<typeof PostStatus401ParamsSchema>
export type PostStatus401Response = undefined
}
/**
* Agentic Security client.
*
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject.
*/
export class SecurityClient extends AIFunctionsProvider {
protected readonly ky: KyInstance
protected readonly apiBaseUrl: string
constructor({
apiBaseUrl = security.apiBaseUrl,
ky = defaultKy
}: {
apiKey?: string
apiBaseUrl?: string
ky?: KyInstance
} = {}) {
super()
this.apiBaseUrl = apiBaseUrl
this.ky = ky.extend({
prefixUrl: apiBaseUrl
})
}
/**
* `apiKey` auth will be supplied within an `apiKey` query parameter.
*/
@aiFunction({
name: 'get_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`apiKey\` query parameter.`,
inputSchema: security.GetAnythingApiKeyParamsSchema
})
async getAnythingApiKey(
_params: security.GetAnythingApiKeyParams
): Promise<security.GetAnythingApiKeyResponse> {
return this.ky
.get('/anything/apiKey')
.json<security.GetAnythingApiKeyResponse>()
}
/**
* `apiKey` auth will be supplied within an `api_key` cookie.
*/
@aiFunction({
name: 'post_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`api_key\` cookie.`,
inputSchema: security.PostAnythingApiKeyParamsSchema
})
async postAnythingApiKey(
_params: security.PostAnythingApiKeyParams
): Promise<security.PostAnythingApiKeyResponse> {
return this.ky
.post('/anything/apiKey')
.json<security.PostAnythingApiKeyResponse>()
}
/**
* `apiKey` auth will be supplied within an `X-API-KEY` header.
*/
@aiFunction({
name: 'put_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`X-API-KEY\` header.`,
inputSchema: security.PutAnythingApiKeyParamsSchema
})
async putAnythingApiKey(
_params: security.PutAnythingApiKeyParams
): Promise<security.PutAnythingApiKeyResponse> {
return this.ky
.put('/anything/apiKey')
.json<security.PutAnythingApiKeyResponse>()
}
/**
* Authentication credentials will be supplied within a `Basic` `Authorization` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.
*/
@aiFunction({
name: 'post_anything_basic',
description: `Authentication credentials will be supplied within a \`Basic\` \`Authorization\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.`,
inputSchema: security.PostAnythingBasicParamsSchema
})
async postAnythingBasic(
_params: security.PostAnythingBasicParams
): Promise<security.PostAnythingBasicResponse> {
return this.ky
.post('/anything/basic')
.json<security.PostAnythingBasicResponse>()
}
/**
* Authentication credentials will be supplied within a `Bearer` `Authorization` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.
*/
@aiFunction({
name: 'post_anything_bearer',
description: `Authentication credentials will be supplied within a \`Bearer\` \`Authorization\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.`,
inputSchema: security.PostAnythingBearerParamsSchema
})
async postAnythingBearer(
_params: security.PostAnythingBearerParams
): Promise<security.PostAnythingBearerResponse> {
return this.ky
.post('/anything/bearer')
.json<security.PostAnythingBearerResponse>()
}
/**
* Authentication credentials will be supplied within a `Bearer` `Authorization` header, but its data should be controlled as a JWT.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample
>
> We currently do not support any special handling for this so they're handled as a standard `Bearer` authentication token.
*/
@aiFunction({
name: 'put_anything_bearer',
description: `Authentication credentials will be supplied within a \`Bearer\` \`Authorization\` header, but its data should be controlled as a JWT.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample
>
> We currently do not support any special handling for this so they're handled as a standard \`Bearer\` authentication token.`,
inputSchema: security.PutAnythingBearerParamsSchema
})
async putAnythingBearer(
_params: security.PutAnythingBearerParams
): Promise<security.PutAnythingBearerResponse> {
return this.ky
.put('/anything/bearer')
.json<security.PutAnythingBearerResponse>()
}
/**
* >
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.
*/
@aiFunction({
name: 'get_anything_oauth2',
description: `>
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.GetAnythingOauth2ParamsSchema
})
async getAnythingOauth2(
_params: security.GetAnythingOauth2Params
): Promise<security.GetAnythingOauth2Response> {
return this.ky
.get('/anything/oauth2')
.json<security.GetAnythingOauth2Response>()
}
/**
* >
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.
*/
@aiFunction({
name: 'post_anything_oauth2',
description: `>
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PostAnythingOauth2ParamsSchema
})
async postAnythingOauth2(
_params: security.PostAnythingOauth2Params
): Promise<security.PostAnythingOauth2Response> {
return this.ky
.post('/anything/oauth2')
.json<security.PostAnythingOauth2Response>()
}
/**
* >
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.
*/
@aiFunction({
name: 'put_anything_oauth2',
description: `>
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PutAnythingOauth2ParamsSchema
})
async putAnythingOauth2(
_params: security.PutAnythingOauth2Params
): Promise<security.PutAnythingOauth2Response> {
return this.ky
.put('/anything/oauth2')
.json<security.PutAnythingOauth2Response>()
}
/**
* >
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.
*/
@aiFunction({
name: 'delete_anything_oauth2',
description: `>
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.DeleteAnythingOauth2ParamsSchema
})
async deleteAnythingOauth2(
_params: security.DeleteAnythingOauth2Params
): Promise<security.DeleteAnythingOauth2Response> {
return this.ky
.delete('/anything/oauth2')
.json<security.DeleteAnythingOauth2Response>()
}
/**
* >
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.
*/
@aiFunction({
name: 'patch_anything_oauth2',
description: `>
> 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.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PatchAnythingOauth2ParamsSchema
})
async patchAnythingOauth2(
_params: security.PatchAnythingOauth2Params
): Promise<security.PatchAnythingOauth2Response> {
return this.ky
.patch('/anything/oauth2')
.json<security.PatchAnythingOauth2Response>()
}
/**
* 🚧 This is not supported.
*/
@aiFunction({
name: 'post_anything_open_id_connect',
description: `🚧 This is not supported.`,
inputSchema: security.PostAnythingOpenIdConnectParamsSchema
})
async postAnythingOpenIdConnect(
_params: security.PostAnythingOpenIdConnectParams
): Promise<security.PostAnythingOpenIdConnectResponse> {
return this.ky
.post('/anything/openIdConnect')
.json<security.PostAnythingOpenIdConnectResponse>()
}
/**
* This operation does not have any authentication requirements.
*/
@aiFunction({
name: 'post_anything_no_auth',
description: `This operation does not have any authentication requirements.`,
inputSchema: security.PostAnythingNoAuthParamsSchema
})
async postAnythingNoAuth(
_params: security.PostAnythingNoAuthParams
): Promise<security.PostAnythingNoAuthResponse> {
return this.ky
.post('/anything/no-auth')
.json<security.PostAnythingNoAuthResponse>()
}
/**
* The `apiKey` query parameter auth on this operation is optional.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object.
*/
@aiFunction({
name: 'get_anything_optional_auth',
description: `The \`apiKey\` query parameter auth on this operation is optional.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object.`,
inputSchema: security.GetAnythingOptionalAuthParamsSchema
})
async getAnythingOptionalAuth(
_params: security.GetAnythingOptionalAuthParams
): Promise<security.GetAnythingOptionalAuthResponse> {
return this.ky
.get('/anything/optional-auth')
.json<security.GetAnythingOptionalAuthResponse>()
}
/**
* This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.
*/
@aiFunction({
name: 'post_status401',
description: `This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.`,
inputSchema: security.PostStatus401ParamsSchema
})
async postStatus401(
_params: security.PostStatus401Params
): Promise<security.PostStatus401Response> {
return this.ky.post('/status/401').json<security.PostStatus401Response>()
}
}

Wyświetl plik

@ -0,0 +1,138 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace tictactoe {
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
/** Winner of the game. `.` means nobody has won yet. */
export const WinnerSchema = z
.enum(['.', 'X', 'O'])
.describe('Winner of the game. `.` means nobody has won yet.')
export type Winner = z.infer<typeof WinnerSchema>
/** Possible values for a board square. `.` means empty square. */
export const MarkSchema = z
.enum(['.', 'X', 'O'])
.describe('Possible values for a board square. `.` means empty square.')
export type Mark = z.infer<typeof MarkSchema>
export const BoardSchema = z
.array(z.array(MarkSchema).min(3).max(3))
.min(3)
.max(3)
export type Board = z.infer<typeof BoardSchema>
export const StatusSchema = z.object({
winner: WinnerSchema.optional(),
board: BoardSchema.optional()
})
export type Status = z.infer<typeof StatusSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetBoardParamsSchema = z.object({})
export type GetBoardParams = z.infer<typeof GetBoardParamsSchema>
export const GetBoardResponseSchema = StatusSchema
export type GetBoardResponse = z.infer<typeof GetBoardResponseSchema>
export const GetSquareParamsSchema = z.object({})
export type GetSquareParams = z.infer<typeof GetSquareParamsSchema>
export const GetSquareResponseSchema = MarkSchema
export type GetSquareResponse = z.infer<typeof GetSquareResponseSchema>
export const PutSquareParamsSchema = MarkSchema
export type PutSquareParams = z.infer<typeof PutSquareParamsSchema>
export const PutSquareResponseSchema = StatusSchema
export type PutSquareResponse = z.infer<typeof PutSquareResponseSchema>
}
/**
* Agentic TicTacToe client.
*
* This API allows writing down marks on a Tic Tac Toe board
and requesting the state of the board or of individual squares.
.
*/
export class TicTacToeClient extends AIFunctionsProvider {
protected readonly ky: KyInstance
protected readonly apiBaseUrl: string
constructor({
apiBaseUrl,
ky = defaultKy
}: {
apiKey?: string
apiBaseUrl?: string
ky?: KyInstance
} = {}) {
super()
this.apiBaseUrl = apiBaseUrl
this.ky = ky.extend({
prefixUrl: apiBaseUrl
})
}
/**
* Retrieves the current state of the board and the winner.
*/
@aiFunction({
name: 'get_board',
description: `Retrieves the current state of the board and the winner.`,
inputSchema: tictactoe.GetBoardParamsSchema
})
async getBoard(
_params: tictactoe.GetBoardParams
): Promise<tictactoe.GetBoardResponse> {
return this.ky.get('/board').json<tictactoe.GetBoardResponse>()
}
/**
* Retrieves the requested square.
*/
@aiFunction({
name: 'get_square',
description: `Retrieves the requested square.`,
inputSchema: tictactoe.GetSquareParamsSchema
})
async getSquare(
_params: tictactoe.GetSquareParams
): Promise<tictactoe.GetSquareResponse> {
return this.ky
.get('/board/{row}/{column}')
.json<tictactoe.GetSquareResponse>()
}
/**
* Places a mark on the board and retrieves the whole board and the winner (if any).
*/
@aiFunction({
name: 'put_square',
description: `Places a mark on the board and retrieves the whole board and the winner (if any).`,
inputSchema: tictactoe.PutSquareParamsSchema
})
async putSquare(
_params: tictactoe.PutSquareParams
): Promise<tictactoe.PutSquareResponse> {
return this.ky
.put('/board/{row}/{column}')
.json<tictactoe.PutSquareResponse>()
}
}

Wyświetl plik

@ -1,988 +0,0 @@
{
"openapi": "3.1.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v2"
}
],
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
},
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Access to Petstore orders"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"paths": {
"/pet": {
"post": {
"tags": ["pet"],
"summary": "Add a new pet to the store",
"description": "",
"operationId": "addPet",
"parameters": [],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
],
"requestBody": {
"$ref": "#/components/requestBodies/Pet"
}
},
"put": {
"tags": ["pet"],
"summary": "Update an existing pet",
"description": "",
"operationId": "updatePet",
"parameters": [],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
},
"405": {
"description": "Validation exception"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
],
"requestBody": {
"$ref": "#/components/requestBodies/Pet"
}
}
},
"/pet/findByStatus": {
"get": {
"tags": ["pet"],
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma separated strings",
"operationId": "findPetsByStatus",
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"explode": true,
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": ["available", "pending", "sold"],
"default": "available"
}
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"400": {
"description": "Invalid status value"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
]
}
},
"/pet/findByTags": {
"get": {
"tags": ["pet"],
"summary": "Finds Pets by tags",
"description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
"operationId": "findPetsByTags",
"parameters": [
{
"name": "tags",
"in": "query",
"description": "Tags to filter by",
"required": true,
"explode": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"400": {
"description": "Invalid tag value"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
],
"deprecated": true
}
},
"/pet/{petId}": {
"get": {
"tags": ["pet"],
"summary": "Find pet by ID",
"description": "Returns a single pet",
"operationId": "getPetById",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to return",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
},
"default": {
"description": "successful response"
}
},
"security": [
{
"api_key": []
}
]
},
"post": {
"tags": ["pet"],
"summary": "Updates a pet in the store with form data",
"description": "",
"operationId": "updatePetWithForm",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
],
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object",
"properties": {
"name": {
"description": "Updated name of the pet",
"type": "string"
},
"status": {
"description": "Updated status of the pet",
"type": "string"
}
}
}
}
}
}
},
"delete": {
"tags": ["pet"],
"summary": "Deletes a pet",
"description": "",
"operationId": "deletePet",
"parameters": [
{
"name": "api_key",
"in": "header",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
]
}
},
"/pet/{petId}/uploadImage": {
"post": {
"tags": ["pet"],
"summary": "uploads an image",
"description": "",
"operationId": "uploadFile",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiResponse"
}
}
}
}
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
}
],
"requestBody": {
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
},
"/store/inventory": {
"get": {
"tags": ["store"],
"summary": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"operationId": "getInventory",
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int32"
}
}
}
}
}
},
"security": [
{
"api_key": []
}
]
}
},
"/store/order": {
"post": {
"tags": ["store"],
"summary": "Place an order for a pet",
"description": "",
"operationId": "placeOrder",
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Order"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"400": {
"description": "Invalid Order"
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
},
"description": "order placed for purchasing the pet",
"required": true
}
}
},
"/store/order/{orderId}": {
"get": {
"tags": ["store"],
"summary": "Find purchase order by ID",
"description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions",
"operationId": "getOrderById",
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of pet that needs to be fetched",
"required": true,
"schema": {
"type": "integer",
"format": "int64",
"minimum": 1,
"maximum": 10
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Order"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Order not found"
}
}
},
"delete": {
"tags": ["store"],
"summary": "Delete purchase order by ID",
"description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors",
"operationId": "deleteOrder",
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of the order that needs to be deleted",
"required": true,
"schema": {
"type": "integer",
"format": "int64",
"minimum": 1
}
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Order not found"
}
}
}
},
"/user": {
"post": {
"tags": ["user"],
"summary": "Create user",
"description": "This can only be done by the logged in user.",
"operationId": "createUser",
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
},
"description": "Created user object",
"required": true
}
}
},
"/user/createWithArray": {
"post": {
"tags": ["user"],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithArrayInput",
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
},
"requestBody": {
"$ref": "#/components/requestBodies/UserArray"
}
}
},
"/user/createWithList": {
"post": {
"tags": ["user"],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithListInput",
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
},
"requestBody": {
"$ref": "#/components/requestBodies/UserArray"
}
}
},
"/user/login": {
"get": {
"tags": ["user"],
"summary": "Logs user into the system",
"description": "",
"operationId": "loginUser",
"parameters": [
{
"name": "username",
"in": "query",
"description": "The user name for login",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "password",
"in": "query",
"description": "The password for login in clear text",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Rate-Limit": {
"description": "calls per hour allowed by the user",
"schema": {
"type": "integer",
"format": "int32"
}
},
"X-Expires-After": {
"description": "date in UTC when token expires",
"schema": {
"type": "string",
"format": "date-time"
}
}
},
"content": {
"application/xml": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
}
}
},
"400": {
"description": "Invalid username/password supplied"
}
}
}
},
"/user/logout": {
"get": {
"tags": ["user"],
"summary": "Logs out current logged in user session",
"description": "",
"operationId": "logoutUser",
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/{username}": {
"get": {
"tags": ["user"],
"summary": "Get user by user name",
"description": "",
"operationId": "getUserByName",
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be fetched. Use user1 for testing. ",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"$ref": "#/components/schemas/User"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"400": {
"description": "Invalid username supplied"
},
"404": {
"description": "User not found"
}
}
},
"put": {
"tags": ["user"],
"summary": "Updated user",
"description": "This can only be done by the logged in user.",
"operationId": "updateUser",
"parameters": [
{
"name": "username",
"in": "path",
"description": "name that need to be updated",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "Invalid user supplied"
},
"404": {
"description": "User not found"
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
},
"description": "Updated user object",
"required": true
}
},
"delete": {
"tags": ["user"],
"summary": "Delete user",
"description": "This can only be done by the logged in user.",
"operationId": "deleteUser",
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be deleted",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "Invalid username supplied"
},
"404": {
"description": "User not found"
}
}
}
}
},
"components": {
"schemas": {
"Order": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"shipDate": {
"type": "string",
"format": "date-time"
},
"status": {
"type": "string",
"description": "Order Status",
"enum": ["placed", "approved", "delivered"]
},
"complete": {
"type": "boolean",
"default": false
}
},
"xml": {
"name": "Order"
}
},
"Category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
},
"xml": {
"name": "User"
}
},
"Tag": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
},
"Pet": {
"type": "object",
"required": ["name", "photoUrls"],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"readOnly": true
},
"category": {
"$ref": "#/components/schemas/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true
},
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "#/components/schemas/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": ["available", "pending", "sold"]
}
},
"xml": {
"name": "Pet"
}
},
"ApiResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
},
"requestBodies": {
"Pet": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
},
"description": "Pet object that needs to be added to the store",
"required": true
},
"UserArray": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
}
},
"description": "List of user object",
"required": true
}
},
"securitySchemes": {
"petstore_auth": {
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
},
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
}
}
}
}

Wyświetl plik

@ -1,397 +0,0 @@
{
"openapi": "3.1.0",
"info": {
"version": "1.0.0",
"title": "Support for different security types",
"description": "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securitySchemeObject"
},
"servers": [
{
"url": "https://httpbin.org"
}
],
"tags": [
{
"name": "API Key"
},
{
"name": "HTTP"
},
{
"name": "Mutual TLS"
},
{
"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.1.0.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.1.0.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.1.0.md#basic-authentication-sample\n\n> We currently do not support any special handling for this so they're handled as a standard `Bearer` authentication token.",
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"bearer_jwt": []
}
]
}
},
"/anything/mutualTLS": {
"post": {
"summary": "`mutualTLS` auth",
"description": "🚧 This is not supported.",
"tags": ["Mutual TLS"],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"mutualTLS": []
}
]
}
},
"/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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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"
}
}
}
},
"/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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.md#jwt-bearer-sample"
},
"mutualTLS": {
"type": "mutualTLS",
"description": "Requires a specific mutual TLS certificate to use when making a HTTP request. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23"
},
"oauth2": {
"type": "oauth2",
"description": "An OAuth 2 security flow. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.md#fixed-fields-23"
}
}
}
}

Wyświetl plik

@ -24,7 +24,8 @@
"clean": "del dist",
"test": "run-s test:*",
"test:lint": "eslint .",
"test:typecheck": "tsc --noEmit"
"test:typecheck": "tsc --noEmit",
"test:unit": "vitest run"
},
"dependencies": {
"@agentic/core": "workspace:*",

Wyświetl plik

@ -0,0 +1,40 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, test } from 'vitest'
import { generateTSFromOpenAPI } from './generate-ts-from-openapi'
const fixtures = [
'firecrawl.json',
// 'github.json', // TODO: not working 100% yet
'notion.json',
'pet-store.json',
'petstore-expanded.json',
'security.json',
// 'stripe.json', // TODO: not working 100% yet
'tic-tac-toe.json'
]
const dirname = path.join(fileURLToPath(import.meta.url), '..', '..')
describe('openapi-to-ts', () => {
for (const fixture of fixtures) {
test(
fixture,
{
timeout: 60_000
},
async () => {
const fixturePath = path.join(dirname, 'fixtures', 'openapi', fixture)
const outputDir = path.join(dirname, 'fixtures', 'generated')
const result = await generateTSFromOpenAPI({
openapiFilePath: fixturePath,
outputDir
})
expect(result).toMatchSnapshot()
}
)
}
})

Wyświetl plik

@ -699,8 +699,9 @@ export class ${clientName} extends AIFunctionsProvider {
'}'
].join('\n\n')
)
).replaceAll(/z\s*\.object\({}\)\s*\.merge\(([^)]*)\)/gm, '$1')
// .replaceAll(/\/\*\*(\S.*\S)\*\//g, '/** $1 */')
)
.replaceAll(/z\s*\.object\({}\)\s*\.merge\(([^)]*)\)/gm, '$1')
.replaceAll(/\/\*\*(\S.*\S)\*\//g, '/** $1 */')
if (dryRun) {
return output