Skip to content
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
18 changes: 18 additions & 0 deletions examples/refundReasons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# yaml-language-server: $schema=../schema-definitions/refundReasons.json
refundReasons:
- id: WRONG_TICKET_TYPE
name:
- lang: nob
value: Feil billettype
- lang: nno
value: Feil billettype
- lang: eng
value: Wrong ticket type
- id: OTHER
name:
- lang: nob
value: Annet
- lang: nno
value: Anna
- lang: eng
value: Other
50 changes: 50 additions & 0 deletions schema-definitions/refundReasons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "RefundReasons",
"type": "object",
"properties": {
"refundReasons": {
"default": [],
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"lang": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": ["lang", "value"]
},
{
"type": "object",
"properties": {
"language": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
]
}
}
},
"required": ["id", "name"]
}
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './other';
export * from './reference-data';
export * from './stop-signal-button-config';
export * from './known-qr-code-urls';
export * from './refund-reasons';
14 changes: 14 additions & 0 deletions src/refund-reasons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {z} from 'zod';
import {LanguageAndTextTypeArray} from './common';

export const RefundReason = z.object({
id: z.string(),
name: LanguageAndTextTypeArray,
});

export const RefundReasons = z.object({
refundReasons: z.array(RefundReason).default([]),
});

export type RefundReasonType = z.infer<typeof RefundReason>;
export type RefundReasonsType = z.infer<typeof RefundReasons>;
3 changes: 3 additions & 0 deletions src/tools/specifications-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {Other} from '../other';
import {ReferenceData} from '../reference-data';
import {StopSignalButtonConfig} from '../stop-signal-button-config';
import {KnownQrCodeUrls} from '../known-qr-code-urls';
import {RefundReasons} from '../refund-reasons';
import {AppVersionedItem, AppVersionedItemSchema} from '../common';

// All supported specifications
Expand All @@ -36,6 +37,7 @@ export const specifications = [
'referenceData',
'stopSignalButtonConfig',
'knownQrCodeUrls',
'refundReasons',
] as const;

export type SchemaNames = (typeof specifications)[number];
Expand Down Expand Up @@ -76,6 +78,7 @@ export const schemaTypes = {
referenceData: ReferenceData,
stopSignalButtonConfig: StopSignalButtonConfig,
knownQrCodeUrls: KnownQrCodeUrls.meta({title: 'KnownQrCodeUrls'}),
refundReasons: RefundReasons.meta({title: 'RefundReasons'}),
} satisfies Record<SchemaNames, unknown>;

// All correctly supported schema types as JSON Schema data structures
Expand Down
Loading