Skip to content

Commit

Permalink
Merge pull request #222 from maykinmedia/feature/208-expand-openapi-bug
Browse files Browse the repository at this point in the history
Feature/208 expand openapi bug
  • Loading branch information
bart-maykin authored Aug 14, 2024
2 parents 8fd6cc0 + bb52fff commit 315786a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,6 @@ class Meta:
}


class BetrokkeneForeignkeySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Betrokkene
fields = (
"uuid",
"url",
)
extra_kwargs = {
"uuid": {"required": True, "validators": [betrokkene_exists]},
"url": {
"view_name": "klantinteracties:betrokkene-detail",
"lookup_field": "uuid",
"help_text": _("De unieke URL van deze betrokkene binnen deze API."),
},
}


class BezoekadresSerializer(GegevensGroepSerializer):
class Meta:
model = Betrokkene
Expand Down Expand Up @@ -282,7 +265,7 @@ class KlantcontactSerializer(serializers.HyperlinkedModelSerializer):
),
many=True,
)
had_betrokkenen = BetrokkeneForeignkeySerializer(
had_betrokkenen = BetrokkeneForeignKeySerializer(
read_only=True,
source="betrokkene_set",
help_text=_("Persoon of organisatie die betrokken was bij een klantcontact."),
Expand Down
55 changes: 23 additions & 32 deletions src/openklant/components/klantinteracties/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2863,22 +2863,6 @@ components:
required:
- url
- uuid
BetrokkeneForeignkey:
type: object
properties:
uuid:
type: string
format: uuid
description: Unieke (technische) identificatiecode van de betrokkene bij
klantcontact.
url:
type: string
format: uri
readOnly: true
description: De unieke URL van deze betrokkene binnen deze API.
required:
- url
- uuid
Bezoekadres:
type: object
description: |-
Expand Down Expand Up @@ -3233,24 +3217,28 @@ components:
`expand` parameter
properties:
had_betrokkenen:
allOf:
- $ref: '#/components/schemas/Betrokkene'
type: array
items:
$ref: '#/components/schemas/Betrokkene'
readOnly: true
description: Persoon of organisatie die betrokken was bij een klantcontact.
leidde_tot_interne_taken:
allOf:
- $ref: '#/components/schemas/InterneTaak'
type: array
items:
$ref: '#/components/schemas/InterneTaak'
readOnly: true
description: Klantcontact dat leidde tot een interne taak.
ging_over_onderwerpobjecten:
allOf:
- $ref: '#/components/schemas/Onderwerpobject'
type: array
items:
$ref: '#/components/schemas/Onderwerpobject'
readOnly: true
description: Onderwerpobject dat tijdens een klantcontact aan de orde
was.
omvatte_bijlagen:
allOf:
- $ref: '#/components/schemas/Bijlage'
type: array
items:
$ref: '#/components/schemas/Bijlage'
readOnly: true
description: Bijlage die (een deel van) de inhoud van het klantcontact
beschrijft.
Expand All @@ -3265,19 +3253,22 @@ components:
`expand` parameter
properties:
digitale_adressen:
allOf:
- $ref: '#/components/schemas/DigitaalAdres'
type: array
items:
$ref: '#/components/schemas/DigitaalAdres'
nullable: true
description: Digitaal adresen dat een partij verstrekte voor gebruik
bij toekomstig contact met de gemeente.
betrokkenen:
allOf:
- $ref: '#/components/schemas/Betrokkene'
type: array
items:
$ref: '#/components/schemas/Betrokkene'
readOnly: true
description: Betrokkene bij klantcontact die een partij was.
categorie_relaties:
allOf:
- $ref: '#/components/schemas/CategorieRelatie'
type: array
items:
$ref: '#/components/schemas/CategorieRelatie'
readOnly: true
description: 'De Categorie relaties van een partij: Let op: Dit attribuut
is EXPERIMENTEEL.'
Expand Down Expand Up @@ -3392,7 +3383,7 @@ components:
hadBetrokkenen:
type: array
items:
$ref: '#/components/schemas/BetrokkeneForeignkey'
$ref: '#/components/schemas/BetrokkeneForeignKey'
readOnly: true
description: Persoon of organisatie die betrokken was bij een klantcontact.
leiddeTotInterneTaken:
Expand Down Expand Up @@ -4591,7 +4582,7 @@ components:
hadBetrokkenen:
type: array
items:
$ref: '#/components/schemas/BetrokkeneForeignkey'
$ref: '#/components/schemas/BetrokkeneForeignKey'
readOnly: true
description: Persoon of organisatie die betrokken was bij een klantcontact.
leiddeTotInterneTaken:
Expand Down
7 changes: 6 additions & 1 deletion src/openklant/components/utils/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def get_expand_response(self, serializer, base_response, direction):

inclusion_ref = self.resolve_serializer(inclusion_serializer, direction).ref

many = True if hasattr(inclusion_field, "child_relation") else False
many = (
True
if hasattr(inclusion_field, "child_relation")
or hasattr(inclusion_field, "many")
else False
)
if many:
inclusion_schema = append_meta(build_array_type(inclusion_ref), meta)
else:
Expand Down

0 comments on commit 315786a

Please sign in to comment.