Skip to content

Commit

Permalink
reproduce issue getkin#618
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
  • Loading branch information
fenollp committed Oct 13, 2022
1 parent 330c142 commit a55022d
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
41 changes: 41 additions & 0 deletions openapi3/issue618_test.go
@@ -0,0 +1,41 @@
package openapi3

import (
"testing"

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

func TestIssue618(t *testing.T) {
spec := `
openapi: 3.0.0
info:
title: foo
version: 0.0.0
paths:
/foo:
get:
responses:
'200':
description: Some description value text
content:
application/json:
schema:
$ref: ./testdata/schema618.yml#/components/schemas/JournalEntry
`[1:]

loader := NewLoader()
loader.IsExternalRefsAllowed = true
ctx := loader.Context

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

doc.InternalizeRefs(ctx, nil)

t.Logf(">>> %+v", doc.Components.Schemas)

require.Contains(t, doc.Components.Schemas, "JournalEntry")
require.Contains(t, doc.Components.Schemas, "Record")
require.Contains(t, doc.Components.Schemas, "Account")
}
62 changes: 62 additions & 0 deletions openapi3/testdata/schema618.yml
@@ -0,0 +1,62 @@
components:
schemas:
Account:
required:
- name
- nature
type: object
properties:
id:
type: string
name:
type: string
description:
type: string
type:
type: string
enum:
- assets
- liabilities
nature:
type: string
enum:
- asset
- liability
Record:
required:
- account
- concept
type: object
properties:
account:
$ref: "#/components/schemas/Account"
concept:
type: string
partial:
type: number
credit:
type: number
debit:
type: number
JournalEntry:
required:
- type
- creationDate
- records
type: object
properties:
id:
type: string
type:
type: string
enum:
- daily
- ingress
- egress
creationDate:
type: string
format: date
records:
type: array
items:
$ref: "#/components/schemas/Record"

0 comments on commit a55022d

Please sign in to comment.