It is great if this library can load with http.FileSystem because we can embed specification files into single binary with Go1.16's embed feature
package main
import (
"embed"
"log"
"net/http"
"github.com/getkin/kin-openapi/openapi3"
)
//go:embed spec/*
var spec embed.FS
func main() {
loader := openapi3.NewSwaggerLoader()
loader.IsExternalRefsAllowed = true
swagger, err := loader.LoadSwaggerFromFileSystem(http.FS(spec), "spec/openapi.yml")
if err != nil {
panic(err)
}
log.Printf("%s\n", swagger.Paths["/foo"].Get.Responses["200"].Value.Content["application/json"].Schema.Value.Properties["foo"].Value.Type)
}
openapi: "3.0.0"
info:
version: "1.0"
title: example
paths:
/foo:
$ref: ./paths/foo.yml
get:
parameters:
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
foo:
type: string
example: foo
It is great if this library can load with http.FileSystem because we can embed specification files into single binary with Go1.16's embed feature