Skip to content

Commit

Permalink
reproduce getkin#542
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
  • Loading branch information
fenollp committed Jun 9, 2022
1 parent 648d6b9 commit 88b06b6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
19 changes: 19 additions & 0 deletions openapi3/issue542_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package openapi3

import (
"testing"

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

func TestIssue542(t *testing.T) {
sl := NewLoader()

doc, err := sl.LoadFromFile("testdata/issue542.yml")
require.NoError(t, err)

err = doc.Validate(sl.Context)
require.NoError(t, err)

require.Empty(t, doc.Components.Schemas["Cat"].Value.AnyOf[1].Value.Properties["offspring"])
}
37 changes: 37 additions & 0 deletions openapi3/testdata/issue542.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Kitten'
discriminator:
propertyName: pet_type
responses:
'200':
description: Updated
components:
schemas:
Cat:
anyOf:
- $ref: '#/components/schemas/Kitten'
- type: object
properties:
hunts:
type: boolean
age:
type: integer
offspring:
Kitten:
$ref: '#/components/schemas/Cat'

0 comments on commit 88b06b6

Please sign in to comment.