Разместите и поместите json тело с чванством Ruby на Rails - PullRequest
0 голосов
/ 26 марта 2020

Я пытаюсь сделать чванство. json файл. get работает нормально даже с {id}, однако мои POST и PUT, похоже, не работают и отправляют

"status": 400, "error": "Bad Request", "exception": "#", в развратных документах.

и для моего пута я получаю

Не удалось отобразить этот компонент, см. Консоль.

Я пользуюсь POSTMAN, и у меня нет проблем с тем, что когда-либо

        "tags": [
          "POST"
        ],
        "summary": "Create new",
        "operationId": "add",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "type": "object",
            "in": "body",
            "name": "params",
            "description": "Create new",
            "required": true,
            "schema": {
              "$ref": "#/definitions/create_new_params"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully have created .",
            "schema": {
              "$ref": "#/definitions/create_new_params"
            }
          },
          "400": {
            "description": "Incorrect params."

          },
          "500": {
            "description": "Error on sending message."

          }
        }
      }
    },    "/api/v1/program/{id}": {
      "put": {
        "description": "Update",
        "tags": [
          "Update"
        ],
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "id",
            "type": "integer",
            "in": "path",
            "required": true
          },
          {
            "in": "body",
            "name": "body",
            "description": "object updating",
            "required": true,
            "schema": {
              "$ref": "#/definitions/create_new_params"
            }
          }
        ],
        "responses": {
          "405": {
            "description": "Validation exception"
          },
          "404": {
            "description": "not found"
          },
          "400": {
            "description": "Invalid ID supplied"
          }
        }
      }
    }
  }, 


and this is my def

```"definitions": {
    "create_new_params": {
      "type": "object",
      "properties": {
        "part1": { // this is part of my json format
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "service": {
              "type": "string"
            },
            "number1": {
              "type": "integer"
            },
            "number2": {
              "type": "integer"
            },
            "number3": {
              "type": "integer"
            },
            "start_date": {
              "type": "string"
            },
            "end_date": {
              "type": "string"
            },
            "min_term": {
              "type": "string"
            },
            "restrictions": {
              "type": "string"
            }
          }
        }
      }
    },
...