Skip to content

nullable not respected on $ref schemas #927

Open
@brandonbloom

Description

@brandonbloom
package openapi3

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestIssueXXX(t *testing.T) {
	spec := `
openapi: 3.0.0
components:
  schemas:
    NullableString:
      type: string
      nullable: true
    NullableRef:
      $ref: "#/components/schemas/String"
      nullable: true
    String:
      type: string
`

	sl := NewLoader()
	doc, err := sl.LoadFromData([]byte(spec))
	require.NoError(t, err)

	require.False(t, doc.Components.Schemas["String"].Value.Nullable)
	require.True(t, doc.Components.Schemas["NullableString"].Value.Nullable)
	require.True(t, doc.Components.Schemas["NullableRef"].Value.Nullable) // this fails!
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions