docovalidate

module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT

README

OAPI Builder

A library for generating OpenAPI specifications and validating request and response in Go.

Features

  • Generating OpenAPI 3.0 specifications
  • Schema validation via libopenapi
  • Flexible schema construction via builder pattern
  • Support for core OpenAPI components:
    • Info
    • Paths
    • Components/Schemas
  • Automatic YAML formatting with proper indentation

Install

go get github.com/IlKhr/docovalidate

How to use

package main

import (
    "log/slog"
    "github.com/IlKhr/docovalidate/pkg/oapi_builder"
)

func main() {
    logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
    builder := oapi_builder.New(logger)

    // Create schemas
    mainInfo := &MainInfoSchema{...}
    paths := []oapi_builder.Schemer{...}
    components := &ComponentsSchema{...}

    // Generate specification
    builder.MustGenerateSchemas(
        oapi_builder.HandlersWithSchemas{
            MainInfoSchemas:   mainInfo,
            PathSchemas:       paths,
            ComponentsSchemas: components,
        },
        "openapi.yaml",
    )
}

Licence

MIT

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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