Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag creation while creating post #396

Open
camelya58 opened this issue Sep 8, 2020 · 0 comments
Open

Fix tag creation while creating post #396

camelya58 opened this issue Sep 8, 2020 · 0 comments

Comments

@camelya58
Copy link
Member

Please, fix code in create and update methods of PostServiceRealization class (2 methods).
When you try in swagger to create or update some post, and fill the field "tags", must create a tag along with the post. And this tag you must find by this id in tag controller.
Consider that tag field "id" must generates automatically.

The situation is the same with nodes. The "id" creates automatically only in field connecting with one node, but nodes field "postId" doesn't generate automatically. You must fix it.

curl -X POST "http://post-reckue.apps.us-east-1.starter.openshift-online.com/posts" -H "accept: */*" -H "Content-Type: application/json" -d "{ \"nodes\": [ { \"node\": { \"type\": \"TEXT\" }, \"source\": \"string\", \"type\": \"TEXT\", \"userId\": \"string\" } ], \"source\": \"string\", \"status\": \"DRAFT\", \"tags\": [ { \"name\": \"string\" } ], \"title\": \"string\", \"userId\": \"string\"}"

Request must be like the following:

{
  "nodes": [
    {
      "node": {
        "type": "TEXT"
      },
      "source": "string",
      "type": "TEXT",
      "userId": "string"
    }
  ],
  "source": "string",
  "status": "DRAFT",
  "tags": [
    {
      "name": "string"
    }
  ],
  "title": "string",
  "userId": "string"
}

Expected response:
200 Ok

{
  "id": "5f57ea2f27706b19aefe4c44",
  "title": "string",
  "nodes": [
    {
      "id": "5f57ea2f27706b19aefe4c43",
      "type": "TEXT",
      "node": {
        "content": null
      },
      "postId": "5f57ea2f27706b19aefe4c44",
      "source": "string",
      "userId": "string",
      "createdDate": 1599597103260,
      "modificationDate": 1599597103260,
      "status": null
    }
  ],
  "source": "string",
  "userId": "string",
  "tags": [
    {
      "id": "5f57ea2f27706b19aefe4c42",
      "name": "string"
    }
  ],
  "createdDate": 1599597103266,
  "modificationDate": 1599597103266,
  "status": "DRAFT"
}

Actual response if you create with nodes field "postId" and tags field "id" :
200 Ok

{
  "id": "5f57ea2f27706b19aefe4c44",
  "title": "string",
  "nodes": [
    {
      "id": "5f57ea2f27706b19aefe4c43",
      "type": "TEXT",
      "node": {
        "content": null
      },
      "postId": "string",
      "source": "string",
      "userId": "string",
      "createdDate": 1599597103260,
      "modificationDate": 1599597103260,
      "status": null
    }
  ],
  "source": "string",
  "userId": "string",
  "tags": [
    {
      "id": "string",
      "name": "string"
    }
  ],
  "createdDate": 1599597103266,
  "modificationDate": 1599597103266,
  "status": "DRAFT"
}

Actual response if you try to create without nodes field "postId" and tags field "id" :
400 Bad Request

{
  "timestamp": "2020-09-08T20:37:29.173+0000",
  "status": 400,
  "error": "Bad Request",
  "errors": [
    {
      "codes": [
        "NotNull.postRequest.nodes[0].postId",
        "NotNull.postRequest.nodes.postId",
        "NotNull.nodes[0].postId",
        "NotNull.nodes.postId",
        "NotNull.postId",
        "NotNull.java.lang.String",
        "NotNull"
      ],
      "arguments": [
        {
          "codes": [
            "postRequest.nodes[0].postId",
            "nodes[0].postId"
          ],
          "arguments": null,
          "defaultMessage": "nodes[0].postId",
          "code": "nodes[0].postId"
        }
      ],
      "defaultMessage": "должно быть задано",
      "objectName": "postRequest",
      "field": "nodes[0].postId",
      "rejectedValue": null,
      "bindingFailure": false,
      "code": "NotNull"
    }
  ],
  "message": "Validation failed for object='postRequest'. Error count: 1",
  "path": "/posts"
}

When you fix it, please describe it in already existed docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants