This project extends the go-chi router to support OpenAPI 3, bringing to you a simple interface to build a router conforming your API contract.

Overview

Go OpenAPI

This project extends the go-chi router to support OpenAPI 3, bringing to you a simple interface to build a router conforming your API contract.

Examples

See _examples/ for more examples.

As easy as:

package main

import (
	_ "embed"
	"net/http"

	"github.com/go-chi/chi/v5"
	"github.com/go-chi/chi/v5/middleware"
	"github.com/go-chi/render"

	"github.com/angelokurtis/go-openapi"
)

//go:embed openapi.yaml
var contract []byte

func main() {
	r := openapi.NewRouter(contract)
	r.Use(middleware.Logger)
	r.HandleOperation("getInvites", func(w http.ResponseWriter, r *http.Request) {
		render.Status(r, http.StatusOK)
		render.JSON(w, r, map[string]string{"operation": "getInvites"})
	})
	r.HandleOperation("createInvite", func(w http.ResponseWriter, r *http.Request) {
		render.Status(r, http.StatusCreated)
	})
	r.HandleOperation("deleteInvite", func(w http.ResponseWriter, r *http.Request) {
		_ = chi.URLParam(r, "inviteId")
		render.Status(r, http.StatusNoContent)
	})
	http.ListenAndServe(":3000", r)
}
You might also like...
Wake up, Samurai. We have a project to build
Wake up, Samurai. We have a project to build

kyoto uikit UIKit for rapid development Requirements kyoto page configured SSA basic knowledge of kyoto (twui only) configured tailwindcss Installatio

MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

Build simple microservice with static data

microservice-static-go So this is just example build microservice with static data, i hope this repo will help you learning golang installation 1. clo

micro-draft-manager is a microservice that helps you to manage unstructured data in your application with sorting and full-text search

micro-draft-manager is a microservice that helps you to manage unstructured data in your application with sorting and full-text search. For example, y

Cortex Gateway: a microservice which strives to help you administrating and operating your Cortex Cluster in multi tenant environments
Cortex Gateway: a microservice which strives to help you administrating and operating your Cortex Cluster in multi tenant environments

Cortex Gateway Cortex Gateway is a microservice which strives to help you administrating and operating your Cortex Cluster in multi tenant environment

Targetrwe api test - This project provides the backend service for the targetrwe test application

Targetrwe-api This project provides the backend service for the targetrwe test a

Public interface definitions of 1C Enterprise

proto Репозиторий содержит файлы для Protobuf (контрактов и описание сервисов) для автоматической генерации классов/структур под языки программировани

📕 twtxt is a Self-Hosted, Twitter™-like Decentralised microBlogging platform. No ads, no tracking, your content, your data!
📕 twtxt is a Self-Hosted, Twitter™-like Decentralised microBlogging platform. No ads, no tracking, your content, your data!

twtxt 📕 twtxt is a Self-Hosted, Twitter™-like Decentralised micro-Blogging platform. No ads, no tracking, your content, your data! Technically twtxt

Go-fastapi: a library to quickly build APIs. It is inspired by Python's popular FastAPI
Go-fastapi: a library to quickly build APIs. It is inspired by Python's popular FastAPI

go-fastapi go-fastapi is a library to quickly build APIs. It is inspired by Pyth

Owner
Tiago Angelo
Tiago Angelo
Pact: a consumer-driven contract testing framework

CDC Pact Pact is a consumer-driven contract testing framework. Born out of a microservices boom, Pact was created to solve the problem of integration

A.Samet İleri 50 Dec 21, 2022
A diff tool for OpenAPI Specification 3

OpenAPI Diff This is a diff tool for OpenAPI Spec 3. It can be used in two ways: Generate a diff report in YAML, Text/Markdown or HTML from the cmd-li

Tufin 156 Jan 5, 2023
UPBit Auto Trading with OpenAPI Golang Module

Go-Bit! UPBit Auto Trading System with OpenAPI 이 레포지토리는 upbit를 위한 자동매매 프로그램을 개발하기 위해 제공하는 go module입니다. Features 구현 작업 진행상황 Sample Code Template shiel

Seongmin Kim 12 Jun 27, 2022
Composable OpenAPI Specification (aka Swagger)

compoas Library for building, composing and serving OpenAPI Specification (aka Swagger). Features This lib provides: golang structs which reflect Open

Graaphs 12 Jun 1, 2022
OpenAPI Client and Server Code Generator

This package contains a set of utilities for generating Go boilerplate code for services based on OpenAPI 3.0 API definitions

Discord Gophers 58 Dec 2, 2022
Entgo openapi example for go

entgo-openapi-example Example app created with ent entgen swagger-editor See https://entgo.io/blog/2021/09/10/openapi-generator/ License MIT Author Ya

mattn 7 Nov 27, 2021
Go types and validation for OpenAPI Specification 3.1

openapi Package openapi is a set of Go types for OpenAPI Specification 3.1. The primary purpose of the package is to assist in generation of OpenAPI d

Chance 21 Nov 10, 2022
Conversion from OpenAPI definitions to krakend configuration.

Description Basic conversion from OpenAPI specification to Krakend config. This is extendable with custom OpenAPI attributes and more support for both

Hamza Oral 13 Dec 13, 2022
Just a quick demo of how you can use automatically generated protobuffer and gRPC code from buf.build

buf.build demo The purpose of this repository is to demonstrate how to use the services offered by buf.build for hosting protobuffer definitions and a

Bjørn Borud 0 Jan 4, 2022
Trying to build an Ecommerce Microservice in Golang and Will try to make it Cloud Native - Learning Example extending the project of Nic Jackson

Golang Server Project Best Practices Dependency Injection :- In simple words, we want our functions and packages to receive the objects they depend on

Ujjwal Sharma 35 Nov 28, 2022