jsonschema

package
v0.0.0-...-3e22abe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(value reflect.Type, additional bool) ([]byte, error)

func Schema

func Schema(target reflect.Type, additional bool) (map[string]any, error)

func WithAdditionalProperties

func WithAdditionalProperties(schema *jsonschema.Schema)

Types

type APIPath

type APIPath struct {
	Path        string      `json:"path"  description:"接口路径"`
	Summary     string      `json:"summary,omitempty"  description:"接口概述"`
	Description string      `json:"description,omitempty"  description:"接口详细说明"`
	Request     *Request    `json:"request,omitempty" description:"请求"`
	Responses   []*Response `json:"responses,omitempty" description:"返回"`
}

func General

func General(path, method string, metadata map[string]string,
	query reflect.Type, req reflect.Type, res reflect.Type) (api APIPath, err error)

General 通用api

type ContentBody

type ContentBody struct {
	Type   string         `json:"type,omitempty" description:"返回类型"`
	Schema map[string]any `json:"schema,omitempty" description:"返回结构"`
}

type Request

type Request struct {
	Method string         `json:"method" description:"请求方法"`
	Query  map[string]any `json:"query,omitempty" description:"请求参数结构"`
	Body   ContentBody    `json:"body,omitempty" description:"请求载荷结构"`
}

type Response

type Response struct {
	Code        int          `json:"code" description:"返回码"`
	Description string       `json:"description,omitempty" description:"返回说明"`
	Body        *ContentBody `json:"body,omitempty" description:"返回结构"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL