我使用组合来解决我的数据类型的问题,而且我在Swagger中遇到了一个最奇怪的错误。它甚至没有行号,尽管我已经将其缩小为一小块代码。
我得到的错误是:
Resolver error
e is undefined摆脱它的最简单的方法是注释掉赞助商的定义。实际上,我只需要注释掉Sponser的最后一个元素,即定义Partners元素的四行。我也可以通过注释掉Partner:后面的两行来消除它。我可以通过从事件类型中删除Contests元素来消除它。
我想这是怎么回事。事件是我的基类型,并包含类型竞赛的数组。但所有其他类型,包括竞赛,包括allOf事件。此外,主办方还包括一组合作伙伴,其中(因为它包括事件)包括竞赛的数组。我想这就是斯威格变得困惑的地方。赞助商有它自己的一系列竞赛,它包括和数组的合作伙伴,其中每个都有自己的一系列竞赛,也。而竞赛也有自己的一系列竞赛。(是的,这与客户的数据设计一致。)我所描述的任何编辑都可以删除两个级别的对象,并使用一个竞赛数组。
有没有其他人见过这样的东西,我能做些什么吗?还是这只是斯威格的一个小问题?
swagger: '2.0'
info:
description: RESTful API to retrieve Titles Metadata
version: 1.0.0
title: Swagger Mystery
host: localhost:8080
schemes:
- https
paths:
/event:
get:
operationId: getEvent
summary: searches names
description: |
Search by names, across all types, or by a specific type.
produces:
- application/json
parameters:
- in: query
name: title
description: name to search for
required: true
type: string
- in: query
name: start
required: false
type: boolean
- in: query
name: type
required: false
type: string
description: |
May be "contest", "partner", "sponsor", or "dancer". If missing, will search for all types.
responses:
'200':
description: search results
# I also don't know why I need to comment these out.
# content:
# application/json:
# schema:
# type: array
# items:
# $ref: '#/definitions/Event'
'400':
description: bad input parameter
definitions:
Event:
type: object
properties:
eventType:
type: string
id:
type: integer
format: int64
name:
type: string
description:
type: string
contests:
type: array
items:
$ref: '#/definitions/Contest'
required:
- id
- name
- description
- contests
- eventType
Contest:
allOf:
- $ref: '#/definitions/Event'
- type: object
properties:
parentEvent:
type: string
venue:
type: string
required:
- parentEvent
- venue
Dancer:
allOf:
- $ref: '#/definitions/Event'
- type: object
properties:
eventInvitationDate:
type: string
format: date
venue:
type: string
required:
- eventInvitationDate
- venue
Sponsor:
allOf:
- $ref: '#/definitions/Event'
- type: object
properties:
invitationDate:
type: string
format: date
parentEvent:
type: string
# commenting out these four lines makes the error go away.
partners:
type: array
items:
$ref: '#/definitions/Partner'
Partner:
allOf:
- $ref: '#/definitions/Event'
type: object
properties:
invitationDate:
type: string
format: date
parentEvent:
type: string
venue:
type: string
required:
- invitationDate
- parentEvent
- venue
# two problems:
# 1. Schema error at definitions['Event'].discriminator
# should be string on line 84 (discriminator:)
# 2. Resolver error:
# e is undefined
# (no line number)发布于 2018-02-14 20:12:57
"Resolver error: e是未定义的“是一个Swagger UI 3.x中的bug,它是由definitions中的循环引用引起的,例如Event是指Contest,它指的是Event。
我也不知道我为什么要评论这些。#内容:# application/json:# schema:# type:数组# items:# $ref:‘#/定义/事件’
content关键字没有在OpenAPI /Swagger2.0中使用,而是在OpenAPI 3.0中引入的。在OpenAPI 2.0中,您可以指定响应媒体类型和schema,如下所示:
produces:
- application/json
responses:
'200':
description: search results
schema:
type: array
...发布于 2022-06-06 03:19:19
只要刷新页面就可以解决这个神秘的错误。
发布于 2020-09-02 10:26:46
此错误是由冗余的spaces.Remove所有冗余空间和检查引起的。
https://stackoverflow.com/questions/48720212
复制相似问题