...

Text file src/github.com/go-openapi/spec/README.md

Documentation: github.com/go-openapi/spec

     1# OpenAPI v2 object model [![Build Status](https://github.com/go-openapi/spec/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/spec/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/spec/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/spec)
     2
     3[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
     4[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/spec/master/LICENSE)
     5[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/spec.svg)](https://pkg.go.dev/github.com/go-openapi/spec)
     6[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/spec)](https://goreportcard.com/report/github.com/go-openapi/spec)
     7
     8The object model for OpenAPI specification documents.
     9
    10### FAQ
    11
    12* What does this do?
    13
    14> 1. This package knows how to marshal and unmarshal Swagger API specifications into a golang object model
    15> 2. It knows how to resolve $ref and expand them to make a single root document
    16
    17* How does it play with the rest of the go-openapi packages ?
    18
    19> 1. This package is at the core of the go-openapi suite of packages and [code generator](https://github.com/go-swagger/go-swagger)
    20> 2. There is a [spec loading package](https://github.com/go-openapi/loads) to fetch specs as JSON or YAML from local or remote locations
    21> 3. There is a [spec validation package](https://github.com/go-openapi/validate) built on top of it
    22> 4. There is a [spec analysis package](https://github.com/go-openapi/analysis) built on top of it, to analyze, flatten, fix and merge spec documents
    23
    24* Does this library support OpenAPI 3?
    25
    26> No.
    27> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0).
    28> There is no plan to make it evolve toward supporting OpenAPI 3.x.
    29> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
    30>
    31> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3
    32
    33* Does the unmarshaling support YAML?
    34
    35> Not directly. The exposed types know only how to unmarshal from JSON.
    36>
    37> In order to load a YAML document as a Swagger spec, you need to use the loaders provided by
    38> github.com/go-openapi/loads
    39>
    40> Take a look at the example there: https://pkg.go.dev/github.com/go-openapi/loads#example-Spec
    41>
    42> See also https://github.com/go-openapi/spec/issues/164
    43
    44* How can I validate a spec?
    45
    46> Validation is provided by [the validate package](http://github.com/go-openapi/validate)
    47
    48* Why do we have an `ID` field for `Schema` which is not part of the swagger spec?
    49
    50> We found jsonschema compatibility more important: since `id` in jsonschema influences
    51> how `$ref` are resolved.
    52> This `id` does not conflict with any property named `id`.
    53>
    54> See also https://github.com/go-openapi/spec/issues/23

View as plain text