Forum Discussion
Hey,
you can consider this as sample open -api specs,getting error at line 41 in swagger editor,want to avoid it.
---
openapi: 3.0.1
info:
title: Test
version: v1
paths:
/v1/getList:
get:
summary: get List.
description: get List.
operationId: getList
responses:
default:
description: get List
content:
application/json:
schema:
$ref: '#/components/schemas/B'
components:
schemas:
A:
title: A
type: object
properties:
field1:
type: string
field2:
type: string
B:
title: B
type: object
properties:
field3:
maxLength: 80
type: string
aList:
type: array
items:
$ref: '#/components/schemas/A'
properties:
field1:
type: string
field2:
type: string
abhijitjadhav67, it looks like YAML indentation was lost when you pasted the example. Could you please either post the file as an attachment, or use the "insert code" button to re-post the YAML? Thanks.
- abhijitjadhav675 years agoNew Contributor
--- openapi: 3.0.1 info: title: Test version: v1 paths: /v1/getList: get: summary: get List. description: get List. operationId: getList responses: default: description: get List content: application/json: schema: $ref: '#/components/schemas/B' components: schemas: A: title: A type: object properties: field1: type: string field2: type: string B: title: B type: object properties: field3: maxLength: 80 type: string aList: type: array items: $ref: '#/components/schemas/A' properties: field1: type: string field2: type: string
- HKosova5 years agoSmartBear Alumni (Retired)
Try this:
B: title: B type: object properties: field3: maxLength: 80 type: string aList: type: array items: $ref: '#/components/schemas/A'
When you use $ref, there's no need to redefine the referenced properties alongside the $ref.
- abhijitjadhav675 years agoNew Contributor
I see,Thank you
Related Content
- 5 years ago
- 12 years ago
- 5 years ago
- 6 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 19 days ago