Different field types for issue fields in REST API (OD-1999)
Senderman opened 2 years ago

Prerequisites

Set up a new field in issue custom fields with the following settings:

  • Type: User
  • Name: Assignees
  • Allow Multiple: true
  • Allow Empty Value: true
  • Name of Empty Value: Not assigned
  • Available choices: all users
  • Default value: no default value
  • Include when issue is opened: true
  • Applicable projects: all

Create 2 issues, say with id 1 and 2.

Assign issue 1 to one user Assign issue 2 to two different users

Steps to reproduce

  • curl -X GET -H 'Authorization: Basic XXX' 'https://code.onedev.io/~api/issues/1/fields'
  • curl -X GET -H 'Authorization: Basic XXX' 'https://code.onedev.io/~api/issues/2/fields'

Expected behavior:

for 1:

{
  "Type": "Task",
  "When": null,
  "Priority": "Normal",
  "Blocked by": null,
  "Service": "Services",
  "Assignees": [ "senderman" ],
  "Resolution": null
}

for 2:

{
  "Type": "Task",
  "When": null,
  "Priority": "Normal",
  "Blocked by": null,
  "Service": "DevOps",
  "Assignees": [
    "senderman",
    "vezono"
  ],
  "Resolution": null
}

Actual behavior:

for 1:

{
  "Type": "Task",
  "When": null,
  "Priority": "Normal",
  "Blocked by": null,
  "Service": "Services",
  "Assignees": "senderman",
  "Resolution": null
}

for 2, the same as in the expected behavior.

So the issue here is that a field than can contain multiple values can be returned both as scalar and array, which makes it difficult for parsing in languages which require strict types such as java.

  • OneDev changed state to 'Closed' 2 years ago
    Previous Value Current Value
    Open
    Closed
  • OneDev commented 2 years ago

    State changed as code fixing the issue is committed (a6e364c7)

  • OneDev changed state to 'Released' 2 years ago
    Previous Value Current Value
    Closed
    Released
  • OneDev commented 2 years ago

    State changed as build OD-5285 is successful

issue 1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
10.9.8
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-1999
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover