swagger-api / swagger-api/swagger-codegen

[PYTHON] Handling multiple responses with codegen

Đang mở
#8,167 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Mustache
Star
17.8k
Fork
6k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I have different type of responses for different status code , consider the contents of swagger.json to be

{
	"swagger": "2.0",
	"info": {
		"title": "My Api",
		"description": "Api for Queue",
		"version": "v1"
	},
	"host": "localhost:8000",
	"schemes": ["http"],
	"basePath": "/api",
	"consumes": ["application/json"],
	"produces": ["application/json"],
	"securityDefinitions": {},
	"security": [{}],
	"paths": {
		"/v1/{name}/get_task": {
			"get": {
				"operationId": "v1_get_task_read",
				"description": "Get the first task from queue \n---",
				"parameters": [{
					"name": "priority",
					"in": "query",
					"required": false,
					"type": "string"
				}],
				"responses": {
					"200": {
						"description": "QueuedTask Object",
						"schema": {
							"$ref": "#/definitions/QueuedTask"
						}
					},
					"204": {
						"description": "null object response"
					}
				},
				"tags": ["v1"]
			},
			"parameters": [{
				"name": "name",
				"in": "path",
				"required": true,
				"type": "string"
			}]
		}
	},
	"definitions": {
		"QueuedTask": {
			"required": ["name"],
			"type": "object",
			"properties": {
				"id": {
					"title": "ID",
					"type": "integer",
					"readOnly": true
				},
				"name": {
					"title": "Name",
					"type": "string",
					"maxLength": 16
				}
			}
		}
	}
}
Swagger codegen version 2.3.1
java -jar swagger-codegen-cli-2.3.1.jar generate -l python -i swagger.json -o outs

swagger_client produced inside outs directory doesn't support None object for 204 response. It tries to deserialize the empty response into QueuedTask object and breaks.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Sử dụng swagger.json được cung cấp và chạy lệnh tạo Python Swagger Codegen 2.3.1 đã nêu. Kiểm tra cách swagger_client được tạo xử lý các phản hồi 200 và 204, tập trung vào phản hồi 204 rỗng. Được xem là hoàn tất khi client được tạo chấp nhận phản hồi 204 mà không cố gắng deserialize nó thành QueuedTask, đồng thời vẫn giữ nguyên hành vi của phản hồi 200.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.