Write API spec in the browser. Try editing the spec below and click the generate button on the right. Validation Errors Coming Soon!
API Documentation
export interface GetAgentByNameRequest
{
name: string;
}
export interface GetAgentByNameResponse
{
error: Error | null;
agent: Agent;
}
Generate request and response models, client SDK, Open API Spec in an instant
Request and Response Models in Every Languages
export interface Agent
{
name: string;
age: number;
department: string;
}
export interface Error
{
code: number;
msg: string;
name: string;
}
export interface GetAgentByNameRequest
{
name: string;
}
export interface GetAgentByNameResponse
{
error: Error | null;
agent: Agent;
}
Generate Http Client From the Spec So You Don't Have to Craft Your Own!
export interface Agent
{
name: string;
age: number;
department: string;
}
export interface Error
{
code: number;
msg: string;
name: string;
}
export interface GetAgentByNameRequest
{
name: string;
}
export interface GetAgentByNameResponse
{
error: Error | null;
agent: Agent;
}
export async function getAgentByName(req: GetAgentByNameRequest, headers?: Record<string, string> ): Promise<GetAgentByNameResponse> {
let defaultHeaders = {
"Content-Type": "application/json",
};
if (headers) {
defaultHeaders = { ...defaultHeaders, ...headers };
}
const response = await fetch( "http://localhost:4010/agents/getAgentByName", {
method: 'POST',
headers: defaultHeaders,
body: JSON.stringify(req)
});
const result: GetAgentByNameResponse = await response.json();
return result;
}
openapi: 3.0.3
info:
title: SecretService
description: This is a generated API Spec
version: This is a generated API Spec
servers:
- url: http://localhost:4010
- url: http://localhost:8080
paths:
/agents/getAgentByName:
post:
operationId: getAgentByName
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GetAgentByNameRequest"
responses:
default:
content:
application/json:
schema:
$ref: "#/components/schemas/GetAgentByNameResponse"
description: default response
components:
schemas:
GetAgentByNameRequest:
type: object
required:
- name
properties:
name:
type: string
GetAgentByNameResponse:
type: object
required:
- error
- agent
properties:
error:
nullable: true
$ref: "#/components/schemas/Error"
agent:
$ref: "#/components/schemas/Agent"
Agent:
type: object
required:
- name
- age
- department
properties:
name:
type: string
age:
type: integer
department:
type: string
Error:
type: object
required:
- code
- msg
- name
properties:
code:
type: integer
msg:
type: string
name:
type: string
{
"openapi": "3.0.3",
"info": {
"title": "SecretService",
"description": "This is a generated API Spec",
"version": "This is a generated API Spec"
},
"servers": [
{
"url": "http://localhost:4010"
},
{
"url": "http://localhost:8080"
}
],
"paths": {
"/agents/getAgentByName": {
"post": {
"operationId": "getAgentByName",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetAgentByNameRequest"
}
}
}
},
"responses": {
"default": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetAgentByNameResponse"
}
}
},
"description": "default response"
}
}
}
}
},
"components": {
"schemas": {
"GetAgentByNameRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
}
}
},
"GetAgentByNameResponse": {
"type": "object",
"required": [
"error",
"agent"
],
"properties": {
"error": {
"nullable": true,
"$ref": "#/components/schemas/Error"
},
"agent": {
"$ref": "#/components/schemas/Agent"
}
}
},
"Agent": {
"type": "object",
"required": [
"name",
"age",
"department"
],
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
},
"department": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": [
"code",
"msg",
"name"
],
"properties": {
"code": {
"type": "integer"
},
"msg": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}
}