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

Feature/208 expand openapi bug #222

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -280,7 +263,7 @@ class KlantcontactSerializer(serializers.HyperlinkedModelSerializer):
),
many=True,
)
had_betrokkenen = BetrokkeneForeignkeySerializer(
had_betrokkenen = BetrokkeneForeignKeySerializer(
annashamray marked this conversation as resolved.
Show resolved Hide resolved
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
@@ -1,4 +1,4 @@
openapi: 3.0.3

Check warning on line 1 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with component klantinteracties

oas3-api-servers
info:
title: klantinteracties
version: 0.0.3
Expand Down Expand Up @@ -2862,22 +2862,6 @@
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 @@ -3232,24 +3216,28 @@
`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 @@ -3264,19 +3252,22 @@
`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 @@ -3391,7 +3382,7 @@
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 @@ -3786,7 +3777,7 @@
type: array
items:
$ref: '#/components/schemas/InterneTaak'
PaginatedKlantcontactList:

Check warning on line 3780 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with component klantinteracties

oas3-unused-components-schema Potentially unused components schema has been detected.
type: object
required:
- count
Expand Down Expand Up @@ -3855,7 +3846,7 @@
type: array
items:
$ref: '#/components/schemas/PartijIdentificator'
PaginatedPartijList:

Check warning on line 3849 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / Run with component klantinteracties

oas3-unused-components-schema Potentially unused components schema has been detected.
type: object
required:
- count
Expand Down Expand Up @@ -4589,7 +4580,7 @@
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
Loading