Skip to content

Commit

Permalink
Samlet regel id og beskrivelse i response for v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsmsa committed Aug 22, 2024
1 parent e4f5bda commit 5d441ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ suspend fun PipelineContext<Unit, ApplicationCall>.respondWithErrorV2(problemer:
?: problemer.firstOrNull { it.regel.id is DomeneRegelId }
?.let { it.httpCode() to FeilV2.FeilKode.AVVIST }
?: (HttpStatusCode.InternalServerError to FeilV2.FeilKode.UKJENT_FEIL)
val melding = problemer.map { it.regel.id.beskrivelse }
.distinct()
.joinToString(". ")
.replace("..", ".")
val melding = if (FeilV2.FeilKode.AVVIST == feilkode) {
"Avvist, se 'aarsakTilAvvisning' for detaljer"
} else problemer.first().regel.id.beskrivelse
call.respond(
httpCode, FeilV2(
melding = melding,
feilKode = feilkode,
aarsakTilAvvisning = if (feilkode == FeilV2.FeilKode.AVVIST) {
AarsakTilAvvisningV2(
beskrivelse = melding,
regel = problemer.map { it.regel.id.apiRegelId() },
regler = problemer.map { ApiRegel(id = it.regel.id.apiRegelId(), beskrivelse = it.regel.id.beskrivelse) },
detaljer = problemer.first().opplysning.map(::opplysningTilApiOpplysning)
)
} else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,10 @@ components:
AarsakTilAvvisningV2:
type: "object"
properties:
beskrivelse:
type: "string"
regel:
regler:
type: "array"
items:
$ref: "#/components/schemas/ApiRegelId"
$ref: "#/components/schemas/ApiRegel"
detaljer:
type: "array"
items:
Expand All @@ -361,6 +359,13 @@ components:
- "beskrivelse"
- "regel"
- "detaljer"
ApiRegel:
type: "object"
properties:
id:
$ref: "#/components/schemas/ApiRegelId"
beskrivelse:
type: "string"
Opplysning:
type: "string"
enum:
Expand Down

0 comments on commit 5d441ad

Please sign in to comment.