Skip to content

Add choice fields for business criticality, platform, lifecycle, and origin#13740

Merged
valentijnscholten merged 3 commits intobugfixfrom
choice-fields-for-product-enumerates
Nov 21, 2025
Merged

Add choice fields for business criticality, platform, lifecycle, and origin#13740
valentijnscholten merged 3 commits intobugfixfrom
choice-fields-for-product-enumerates

Conversation

@Maffooch
Copy link
Copy Markdown
Contributor

@Maffooch Maffooch commented Nov 19, 2025

Introduce choice fields in the ProductSerializer and update the ApiProductFilter to use MultipleChoiceFilter for business criticality, platform, lifecycle, and origin. This enhancement improves data handling and filtering capabilities for these attributes.

Swagger Filters:
image

Swagger Chema defintion:
image

Invalid selection error:

$: curl -k  -X 'GET' \
  'https://localhost/api/v2/products/?business_criticality=very%20important' \
  -H 'accept: application/json' \
  -H 'Authorization: Token XXX' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   263  100   263    0     0   3334      0 --:--:-- --:--:-- --:--:--  3371
{
  "business_criticality": [
    "Select a valid choice. very important is not one of the available choices."
  ],
  "message": "{'business_criticality': [ErrorDetail(string='Select a valid choice. very important is not one of the available choices.', code='invalid_choice')]}"
}

@Maffooch Maffooch requested a review from mtesauro as a code owner November 19, 2025 23:52
@github-actions github-actions Bot added the apiv2 label Nov 19, 2025
@valentijnscholten
Copy link
Copy Markdown
Member

Marking this as draft until it's ready ;-)

@valentijnscholten valentijnscholten marked this pull request as draft November 20, 2025 17:49
@valentijnscholten valentijnscholten added this to the 2.52.3 milestone Nov 20, 2025
@Maffooch Maffooch marked this pull request as ready for review November 20, 2025 22:32
Copy link
Copy Markdown
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@valentijnscholten valentijnscholten merged commit 7ddbd5f into bugfix Nov 21, 2025
280 of 281 checks passed
@Maffooch Maffooch deleted the choice-fields-for-product-enumerates branch January 26, 2026 16:09
Maffooch added a commit to valentijnscholten/django-DefectDojo that referenced this pull request Feb 16, 2026
…origin (DefectDojo#13740)

* feat(serializers, filters): add choice fields for business criticality, platform, lifecycle, and origin

* feat(serializers): allow null values for choice fields in ProductSerializer

* feat(serializers): make choice fields optional in ProductSerializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants