问题描述
我一直在尝试修复 Swagger 无法呈现我的 JSON 响应的错误 - here is an attached picture of it.
控制台没有显示任何错误,所以我正在努力分配问题可能出现的地方 - here is the console result.
这是我的代码:
"paths": {
"/unit/{jobs}": {
"get": {
"tags": [
"Services"
],"summary": "Jobs information","description": "Returns JSON with content of jobs details.","operationId": "unitJobs","security": [
{
"Application": []
},{
"Profile": []
},{
"Authorization": []
}
],"parameters": [
{
"name": "jobs","in": "path","required": true,"schema": {
"type": "string"
},"description": "Jobs"
}
],"responses": {
"200": {
"description": "Success!","content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Job"
}
}
}
}
}
}
}
},"components": {
"securitySchemes": {
"Application": {
"name": "X-Application","type": "apiKey","in": "header"
},"Profile": {
"name": "X-Profile","Authorization": {
"type": "http","scheme": "bearer"
}
},"schemas": {
"Job": {
"properties": {
"id": {
"type": "integer","example": 2584075,"description": "Unique identifier"
},"currency_code": {
"type": "string","example": "GBP","description": "Currency code"
},"payment_method": {
"type": "array"
},"app_time": {
"type": "integer","example": 1504620000,"description": "Appointment time for the job in UTC timestamp"
},"flexible_from": {
"type": "integer","example": null,"description": "Start of timeframe to execute the job in UTC timestamp"
},"flexible_to": {
"type": "integer","description": "End of timeframe to execute the job in UTC timestamp"
},"insufficient_travel_time_warning_time": {
"type": "integer","example": "1504616400","description": "Time up until Pro should leave prevIoUs job in order to get to this job in time in UTC timestamp"
},"total_formatted": {
"type": "string","example": "£97","description": "Price of the service after discounts"
},"base_total_formatted": {
"type": "string","description": "Price of the service before discounts"
},"price_notes": {
"type": "array","example": [
"Credit applied","Compensation included"
],"description": "Description notes for the price of the services."
},"require_summary": {
"type": "integer","example": 4,"description": "\n * `0` - No summary required \n * `1` - Should send summary at the end of the day \n * `2` - Should send summary Now \n * `3` - Can’t proceed until summary sent \n * `4` - Summary sent"
},"work_time": {
"type": "integer","example": 120,"description": "Job duration in minutes"
},"valid_to": {
"type": "integer","example": "1504620000","description": "Time after which job is no more valid and has to be updated in UTC timestamp"
},"attachments.origin_key": {
"type": "string","example": "checklist","description": "\n Identifies where the attachment is coming from: \n * `checklist` - from answering a question that requires attachment \n * `job` - from job screen \n * `configurator` - from booking process when filling a choice item of type attachment"
},"services_price_modifiers": {
"type": "array","example": ""
},"reference_number": {
"type": "string","example": "20082602SYS","description": "Unique identifying number for each job"
},"purchase_order_number": {
"type": "string","example": "12-13-14-15-16","description": "Unique number assigned to a purchase order form"
},"contacts": {
"type": "array","items": {
"$ref": "#/components/schemas/Contact"
}
},"message_templates": {
"type": "array","items": {
"$ref": "#/components/schemas/MessageTemplate"
}
},"decline_reason_groups": {
"type": "array","items": {
"$ref": "#/components/schemas/DeclineReasonGroup"
}
},"icons": {
"type": "array","items": {
"$ref": "#/components/schemas/Icon"
}
}
}
},"Contact": {
"properties": {
"id": {
"type": "integer","example": 203,"value": {
"type": "string","example": "02034042956","description": "Contact number"
},"type": {
"$ref": "#/components/schemas/ContactType"
},"description": {
"type": "string","example": "Customer Service","description": "Name of the corresponding department"
},"display_positions": {
"type": "array","example": [
2,3,7
],"description": ""
}
}
},"MessageTemplate": {
"properties": {
"id": {
"type": "integer","example": 15,"title": {
"type": "string","example": "In front of the property","description": "Template message title"
},"message": {
"type": "string","example": "Dear [CLIENT_NAME],I am in front of your property. Please let me in or call our office on 02034041930. Your Fantastic Professional","description": "The containing text of the message"
},"vars": {
"type": "array","items": {
"$ref": "#/components/schemas/Var"
},},"destination_option_title": {
"type": "string","example": "to office","description": "Optionally defines the destination of the title"
}
}
},"DeclineReasonGroup": {
"properties": {
"title": {
"type": "string","example": "Technical issues","description": "Decline reason title"
},"sort": {
"type": "integer","example": 100,"description": ""
},"decline_reasons": {
"type": "array","items": {
"$ref": "#/components/schemas/DeclineReason"
}
}
}
},"Icon": {
"properties": {
"name": {
"type": "string","example": "Key:","description": "The name of the icon"
},"note": {
"type": "string","example": "Yes","description": "Addiditonal information about the icon"
}
}
},"Var": {
"properties": {
"variable": {
"type": "string","example": "CLIENT_NAME","description": "Different client details"
},"type": {
"$ref": "#/components/schemas/VarType"
},"field": {
"type": "string","example": "clientName","description": "Fields where the client's information is filled"
}
}
},"DeclineReason": {
"properties": {
"id": {
"type": "integer","example": 11,"name": {
"type": "string","example": "Car is broken","description": "The name of a decline reason"
},"requires_comment": {
"type": "boolean","example": true,"description": "Determines whether the comment section is required to be filled "
},"success_message": {
"type": "string","example": "Please contact Stanimir Tomov on 07472761402 - he can find you another.","description": "The message which pops up after the request made is successful"
},"ContactType": {
"type": "integer","enum": [
1,2,4
],"description": "* `1` - Customer Service \n * `2` - Sales \n * `3` - Finance \n * `4` - Other"
},"VarType": {
"type": "string","enum": [
"auto","manual"
],"description": "* `auto` - information being filled automatically \n * `manual` - information being filled manually "
}
}
}
}
解决方法
问题不在于他们自己的响应,而在于 Job 模式中“payment_method”的定义:
您需要在数组定义中定义项目,试试这个:
"payment_method": {
"type": "array","items": {
"type": "string"
}
}