我正在为一个项目做文档。在网站上,所有内容都在预览中正确显示,尽管它显示错误"解析器错误无法读取未定义的属性'0'"。 在 html2 中生成客户端时,响应架构为空。 更新:现在显示完整代码。
我尝试切割一个级别(实体>实体项目>实体响应到实体>实体响应(,错误停止,HTML 仍然没有显示完整数据。
openapi: 3.0.0
info:
description: not working
version: "1.0.0"
title: ...
contact:
email: work@pls.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
#====================================================================================
paths:
/search/nip/{nip}:
get:
operationId: nip?date
parameters:
- in: path
name: nip
required: true
schema:
type: string
minLength: 10
maxLength: 10
description: "Nip"
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityResponse'
'400':
description: ...
description: ...
/search/regon/{regon}:
get:
operationId: regon?date
parameters:
- in: path
name: regon
required: true
schema:
type: string
pattern: '^d{9}$|^d{14}$'
description: ...
example: '364760520'
description: Regon
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityResponse'
'400':
description: ...
description: ...
/search/bank-account/{bank-account}:
get:
operationId: bank-account?date
parameters:
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: ...
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityListResponse'
'400':
description: ...
description: ...
/check/nip/{nip}/bank-account/{bank-account}:
get:
operationId: checkNip
parameters:
- in: path
name: nip
required: true
schema:
type: string
minLength: 10
maxLength: 10
description: "Nip"
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: Numer rachunku bankowego
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityCheckResponse'
'400':
description: ...
description: ...
/check/regon/{regon}/bank-account/{bank-account}:
get:
operationId: checkRegon
parameters:
- in: path
name: regon
required: true
schema:
type: string
pattern: '^d{9}$|^d{14}$'
description: numer identyfikacyjny REGON
example: '364760520'
description: Regon
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: ...
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityCheckResponse'
'400':
description: ...
description: ...
#====================================================================================
components:
schemas:
EntityRequestBase:
properties:
data:
type: string
format: date
example: '2019-05-17'
bank-account:
type: array
items:
type: string
minLength: 26
maxLength: 26
example: '90249000050247256316596736'
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
regon:
type: string
pattern: '^d{9}$|^d{14}$'
description: |
...
example: '364760520'
pesel:
type: string
description: |
...
minLength: 11
maxLength: 11
example: '22222222222'
required:
- data
#====================================================================================
Exception:
properties:
message:
type: string
example: 'error message'
code:
type: integer
required:
- message
- code
#====================================================================================
Person:
properties:
firstName:
type: string
example: Jan
lastName:
type: string
example: Nowak
pesel:
$ref: '#/components/schemas/EntityRequestBase/properties/pesel'
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
#====================================================================================
EntityPerson:
allOf:
- $ref: '#/components/schemas/Person'
- properties:
companyName:
type: string
example: 'Nazwa firmy'
#====================================================================================
EntityCheck:
properties:
accountAssigned:
type: string
example: TAK
description: |
...
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
Entity:
allOf:
- properties:
name:
type: string
example: 'ABC Jan Nowak'
description: |
...
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
statusVat:
type: string
enum:
- C
- Z
- P
example: Z
description: |
...
regon:
type: string
pattern: '^d{9}$|^d{14}$'
description: |
...
example: '364760520'
pesel:
$ref: '#/components/schemas/EntityRequestBase/properties/pesel'
krs:
type: string
example: '0000636771'
maxLength: 10
minLength: 10
description: |
...
residenceAddress:
type: string
example: 'ul/ Taka a Owaka 12 01- Warszawa'
description: |
...
workingAddress:
type: string
representatives:
type: array
items:
$ref: '#/components/schemas/Person'
description: |
...
authorizedClerks:
type: array
items:
$ref: '#/components/schemas/Person'
description: |
...
partners:
type: array
items:
$ref: '#/components/schemas/EntityPerson'
description: |
...
registrationLegalDate:
type: string
format: date
example: '2018-02-21'
registrationDenialDate:
type: string
format: date
example: '2019-02-21'
description: |
...
registrationDenialBasis:
type: string
example: 'Ustawa o podatku od towarów i usług art. 96'
description: |
...
restorationDate:
type: string
format: date
example: '2019-02-21'
description: |
...
restorationBasis:
type: string
example: 'Ustawa o podatku od towarów i usług art. 96'
description: |
...
accountNumbers:
type: array
items:
type: string
minLength: 26
maxLength: 26
example: '90249000050247256316596736'
hasVirtualAccounts:
type: boolean
example: true
description: |
...
required:
- name
#====================================================================================
EntityItem:
allOf:
- properties:
subject:
$ref: '#/components/schemas/Entity'
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
EntityList:
allOf:
- properties:
subjects:
type: array
items:
$ref: '#/components/schemas/Entity'
description: |
...
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
EntityResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityItem'
EntityCheckResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityCheck'
EntityListResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityList'
该问题似乎是由操作 ID 中?
问号引起的:
operationId: nip?date
如果删除问号,HTML2 文档将包含响应架构。
您可以在 https://github.com/swagger-api/swagger-codegen/issues 的 Swagger Codegen 存储库中提交错误报告。
找到了解决方案,这是由于滥用了"allOf",没有它们错误停止并且正确生成了 HTML。只有在"人"中才有意义,所有其他情况都被删除了。