Added support for 3.1 docs and variations, as well as removed duplicated descriptions from sample spec.

This commit is contained in:
Dave Shanley
2022-09-26 15:58:32 -04:00
parent ee4aec4cdb
commit e80b640627
4 changed files with 11 additions and 11 deletions

View File

@@ -217,7 +217,7 @@ func TestNewDocument_Components_Headers(t *testing.T) {
initTest()
h := NewDocument(lowDoc)
assert.Len(t, h.Components.Headers, 1)
assert.Equal(t, "this is a header", h.Components.Headers["UseOil"].Description)
assert.Equal(t, "this is a header example for UseOil", h.Components.Headers["UseOil"].Description)
assert.Equal(t, 318, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Column)
}

View File

@@ -212,7 +212,7 @@ func TestCreateDocument_Paths(t *testing.T) {
param := burgerId.Value.Get.Value.Parameters.Value[1]
assert.Equal(t, "burgerHeader", param.Value.Name.Value)
prop := param.Value.Schema.Value.Schema().FindProperty("burgerTheme").Value
assert.Equal(t, "something about a theme?", prop.Schema().Description.Value)
assert.Equal(t, "something about a theme goes in here?", prop.Schema().Description.Value)
assert.Equal(t, "big-mac", param.Value.Example.Value)
// check content
@@ -284,7 +284,7 @@ func TestCreateDocument_Paths(t *testing.T) {
assert.Len(t, okCode.Value.Headers.Value, 1)
okheader := okCode.Value.FindHeader("UseOil")
assert.NotNil(t, okheader.Value)
assert.Equal(t, "this is a header", okheader.Value.Description.Value)
assert.Equal(t, "this is a header example for UseOil", okheader.Value.Description.Value)
respContent := okCode.Value.FindContent("application/json").Value
assert.NotNil(t, respContent)
@@ -432,7 +432,7 @@ func TestCreateDocument_Components_Headers(t *testing.T) {
useOil := components.FindHeader("UseOil")
assert.NotNil(t, useOil.Value)
assert.Equal(t, "this is a header", useOil.Value.Description.Value)
assert.Equal(t, "this is a header example for UseOil", useOil.Value.Description.Value)
assert.Equal(t, "string", useOil.Value.Schema.Value.Schema().Type.Value.A)
}
@@ -602,4 +602,4 @@ func ExampleCreateDocument() {
// print out email address from the info > contact object.
fmt.Print(document.Info.Value.Contact.Value.Email.Value)
// Output: apiteam@swagger.io
}
}

View File

@@ -89,7 +89,7 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
if spec.SpecType == utils.OpenApi3 {
switch spec.Version {
case "3.0.0", "3.0.1":
case "3.0.0", "3.0.1", "3.0", "3":
spec.APISchema = OpenAPI3SchemaData
case "3.1.0":
spec.APISchema = OpenAPI31SchemaData

View File

@@ -315,7 +315,7 @@ components:
url: https://pb33f.io
headers:
UseOil:
description: this is a header
description: this is a header example for UseOil
schema:
type: string
requestBodies:
@@ -389,10 +389,10 @@ components:
properties:
burgerTheme:
type: string
description: something about a theme?
description: something about a theme goes in here?
burgerTime:
type: number
description: number of burgers ordered this year.
description: number of burgers ordered so far this year.
example: big-mac
description: the name of the burger. use this to order your food
required: true
@@ -423,7 +423,7 @@ components:
schema:
type: string
example: big-mac
description: the name of the burger. use this to order your food
description: the name of the burger. use this to order your tasty burger
required: true
schemas:
Error:
@@ -531,7 +531,7 @@ components:
x-screaming-baby: loud
x-something-something: darkside
externalDocs:
description: "Find out more information about our products)"
description: "Find out more information about our products and services"
url: "https://pb33f.io"
jsonSchemaDialect: https://pb33f.io/schema
webhooks: