fixed a lot of small problems in yaml file, returned to OpenApi 3.0 format

This commit is contained in:
Daniel Schick 2023-12-18 18:10:58 +01:00
parent 5459d99098
commit bd81f01d76
5 changed files with 488 additions and 490 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
openapi: 3.1.0 openapi: 3.0.0
x-stoplight: x-stoplight:
id: iucm9tq7jgu7j id: iucm9tq7jgu7j
info: info:
@ -13,7 +13,6 @@ info:
license: license:
name: Use at your own risk name: Use at your own risk
url: 'https://www.bsmd.de/license' url: 'https://www.bsmd.de/license'
summary: Bremen calling
servers: servers:
- url: 'https://brecaldevel.bsmd-emswe.eu' - url: 'https://brecaldevel.bsmd-emswe.eu'
description: Development server hosted on vcup description: Development server hosted on vcup
@ -395,10 +394,6 @@ components:
type: integer type: integer
shipcall: shipcall:
type: object type: object
required:
- id
- ship_id
- type
properties: properties:
id: id:
$ref: '#/components/schemas/shipcallId' $ref: '#/components/schemas/shipcallId'
@ -485,10 +480,16 @@ components:
created: created:
type: string type: string
format: date-time format: date-time
description: Readonly field set by the database
modified: modified:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: Readonly field set by the database
required:
- id
- ship_id
- type
shipcalls: shipcalls:
type: array type: array
items: items:
@ -496,9 +497,6 @@ components:
times: times:
type: object type: object
description: 'the id parameter needs to be missing on POST and to be present on PUT (Update) calls, otherwise a 400 response will be generated' description: 'the id parameter needs to be missing on POST and to be present on PUT (Update) calls, otherwise a 400 response will be generated'
required:
- shipcall_id
- participant_id
properties: properties:
id: id:
type: integer type: integer
@ -509,6 +507,7 @@ components:
eta_berth_fixed: eta_berth_fixed:
type: boolean type: boolean
nullable: true nullable: true
description: currently unused
etd_berth: etd_berth:
type: string type: string
format: date-time format: date-time
@ -516,6 +515,7 @@ components:
etd_berth_fixed: etd_berth_fixed:
type: boolean type: boolean
nullable: true nullable: true
description: currently unused
lock_time: lock_time:
type: string type: string
format: date-time format: date-time
@ -523,6 +523,7 @@ components:
lock_time_fixed: lock_time_fixed:
type: boolean type: boolean
nullable: true nullable: true
description: currently unused
zone_entry: zone_entry:
type: string type: string
format: date-time format: date-time
@ -530,25 +531,31 @@ components:
zone_entry_fixed: zone_entry_fixed:
type: boolean type: boolean
nullable: true nullable: true
description: currently unused
operations_start: operations_start:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: Start time for terminal operations
operations_end: operations_end:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: End time for terminal operations
remarks: remarks:
type: string type: string
maxLength: 512 maxLength: 512
nullable: true nullable: true
shipcall_id: shipcall_id:
type: integer type: integer
description: Reference to a shipcall id
participant_id: participant_id:
type: integer type: integer
description: Reference to a participant id
berth_id: berth_id:
type: integer type: integer
nullable: true nullable: true
description: Reference to a berth id
berth_info: berth_info:
type: string type: string
nullable: true nullable: true
@ -556,14 +563,19 @@ components:
type: boolean type: boolean
nullable: true nullable: true
participant_type: participant_type:
$ref: '#/components/schemas/ParticipantType2' type: integer
created: created:
type: string type: string
format: date-time format: date-time
description: Readonly field set by the database
modified: modified:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: Readonly field set by the database
required:
- shipcall_id
- participant_id
times_list: times_list:
type: array type: array
items: items:
@ -670,10 +682,12 @@ components:
created: created:
type: string type: string
format: date-time format: date-time
description: Readonly field set by the database
modified: modified:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: Readonly field set by the database
participant: participant:
type: object type: object
description: A organisational entity that participates in Bremen Calling description: A organisational entity that participates in Bremen Calling
@ -694,17 +708,19 @@ components:
maxLength: 64 maxLength: 64
type: type:
type: integer type: integer
description: a logical combinat description: a logical combination (bitflag) of possible values. This cannot be encoded in a Enumeration type with discrete values in OpenAPI version < 3.1. The values are 1=
flags: flags:
type: integer type: integer
nullable: true nullable: true
created: created:
type: string type: string
format: date-time format: date-time
description: Readonly field set by the database
modified: modified:
type: string type: string
format: date-time format: date-time
nullable: true nullable: true
description: Readonly field set by the database
deleted: deleted:
type: boolean type: boolean
default: false default: false
@ -788,52 +804,6 @@ components:
- undefined - undefined
- email - email
- push - push
ParticipantType:
type: integer
enum:
- 1
- 2
- 4
- 8
- 16
- 32
- 64
x-enumDescriptions:
'1': bsmd
'2': terminal
'4': pilot
'8': agency
'16': mooring
'32': port_authority
'64': tug
ParticipantType2:
title: ParticipantType2
x-stoplight:
id: whw0m8x8dq6cg
type: integer
oneOf:
- const: 1
title: bsmd
description: Bremen Schiffsmeldedienst
- const: 2
title: terminal
description: Terminal
- const: 4
title: pilot
description: Pilot
- const: 8
title: agency
description: Agency
- const: 16
title: mooring
description: Mooring
- const: 32
title: port_authority
description: Port Authority
- const: 64
title: tug
description: Tug
description: Enumeration that can take particular values
securitySchemes: securitySchemes:
ApiKey: ApiKey:
type: apiKey type: apiKey

View File

@ -1,6 +1,6 @@
// Copyright (c) 2023 schick Informatik // Copyright (c) 2023 schick Informatik
// Description: some helpers // Description: some helpers
// //
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
@ -11,7 +11,31 @@ namespace BreCalClient
public static class Extensions public static class Extensions
{ {
#region Enum #region Enum
/// <summary>
/// Copied from models clunky I know
/// </summary>
[Flags]
public enum ParticipantType
{
[Description("not assigned")]
NONE = 0,
[Description("BSMD")]
BSMD = 1,
[Description("Terminal")]
TERMINAL = 2,
[Description("Lotsen")]
PILOT = 4,
[Description("Agentur")]
AGENCY = 8,
[Description("Festmacher")]
MOORING = 16,
[Description("Hafenamt")]
PORT_ADMINISTRATION = 32,
[Description("Schlepper")]
TUG = 64,
}
/// <summary> /// <summary>
/// Custom participant flags /// Custom participant flags
@ -42,7 +66,7 @@ namespace BreCalClient
public static bool IsFlagSet(this Participant participant, ParticipantFlag flag) public static bool IsFlagSet(this Participant participant, ParticipantFlag flag)
{ {
return (participant.Flags & (uint)flag) != 0; return (participant.Flags & (uint)flag) != 0;
} }
public static string Truncate(this string value, int maxLength) public static string Truncate(this string value, int maxLength)
{ {

View File

@ -209,13 +209,13 @@ namespace BreCalClient
// this.labelShipName.Content = this.ShipcallControlModel?.Ship?.Name; // this.labelShipName.Content = this.ShipcallControlModel?.Ship?.Name;
switch (this.ShipcallControlModel?.Shipcall?.Type) switch (this.ShipcallControlModel?.Shipcall?.Type)
{ {
case 1: // incoming case ShipcallType.Arrival: // incoming
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_down_red.png")); this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_down_red.png"));
break; break;
case 2: // outgoing case ShipcallType.Departure: // outgoing
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_up_blue.png")); this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_up_blue.png"));
break; break;
case 3: // shifting case ShipcallType.Shifting: // shifting
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_right_green.png")); this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_right_green.png"));
break; break;
default: default:
@ -274,11 +274,11 @@ namespace BreCalClient
this.textBlockBerth.Text = this.ShipcallControlModel?.Berth; this.textBlockBerth.Text = this.ShipcallControlModel?.Berth;
this.textBlockCallsign.Text = this.ShipcallControlModel?.Ship?.Callsign; this.textBlockCallsign.Text = this.ShipcallControlModel?.Ship?.Callsign;
if (this.ShipcallControlModel?.Shipcall?.Type == 1) if (this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival)
{ {
this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Eta?.ToString("dd.MM. HH:mm"); this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Eta?.ToString("dd.MM. HH:mm");
} }
if ((this.ShipcallControlModel?.Shipcall?.Type == 2) || (this.ShipcallControlModel?.Shipcall?.Type == 3)) if ((this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Departure) || (this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Shifting))
{ {
this.labelETA.Text = "ETD"; this.labelETA.Text = "ETD";
this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Etd?.ToString("dd.MM. HH:mm"); this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Etd?.ToString("dd.MM. HH:mm");
@ -290,7 +290,7 @@ namespace BreCalClient
// rename labels if this is not an incoming // rename labels if this is not an incoming
// must be here because there may not be a times record for each participant (yet) // must be here because there may not be a times record for each participant (yet)
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelETAETDAgent.Content = "ETD"; this.labelETAETDAgent.Content = "ETD";
this.labelETAETDMooring.Content = "ETD"; this.labelETAETDMooring.Content = "ETD";
@ -310,7 +310,7 @@ namespace BreCalClient
this.labelAgencyETAETDValue.Content = agencyTimes.EtaBerth.HasValue ? agencyTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelAgencyETAETDValue.Content = agencyTimes.EtaBerth.HasValue ? agencyTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockAgencyRemarks.Text = agencyTimes.Remarks; this.textBlockAgencyRemarks.Text = agencyTimes.Remarks;
this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo; this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelAgencyETAETDValue.Content = agencyTimes.EtdBerth.HasValue ? agencyTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelAgencyETAETDValue.Content = agencyTimes.EtdBerth.HasValue ? agencyTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
@ -330,7 +330,7 @@ namespace BreCalClient
this.labelMooringETAETDValue.Content = mooringTimes.EtaBerth.HasValue ? mooringTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelMooringETAETDValue.Content = mooringTimes.EtaBerth.HasValue ? mooringTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockMooringRemarks.Text = mooringTimes.Remarks; this.textBlockMooringRemarks.Text = mooringTimes.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelMooringETAETDValue.Content = mooringTimes.EtdBerth.HasValue ? mooringTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelMooringETAETDValue.Content = mooringTimes.EtdBerth.HasValue ? mooringTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
@ -346,7 +346,7 @@ namespace BreCalClient
{ {
this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtaBerth.HasValue ? portAuthorityTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtaBerth.HasValue ? portAuthorityTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks; this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtdBerth.HasValue ? portAuthorityTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtdBerth.HasValue ? portAuthorityTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
@ -362,7 +362,7 @@ namespace BreCalClient
{ {
this.labelPilotETAETDValue.Content = pilotTimes.EtaBerth.HasValue ? pilotTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelPilotETAETDValue.Content = pilotTimes.EtaBerth.HasValue ? pilotTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPilotRemarks.Text = pilotTimes.Remarks; this.textBlockPilotRemarks.Text = pilotTimes.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelPilotETAETDValue.Content = pilotTimes.EtdBerth.HasValue ? pilotTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelPilotETAETDValue.Content = pilotTimes.EtdBerth.HasValue ? pilotTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
@ -378,7 +378,7 @@ namespace BreCalClient
{ {
this.labelTugETAETDValue.Content = tugTimes.EtaBerth.HasValue ? tugTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelTugETAETDValue.Content = tugTimes.EtaBerth.HasValue ? tugTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTugRemarks.Text = tugTimes.Remarks; this.textBlockTugRemarks.Text = tugTimes.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelTugETAETDValue.Content = tugTimes.EtdBerth.HasValue ? tugTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelTugETAETDValue.Content = tugTimes.EtdBerth.HasValue ? tugTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
@ -395,7 +395,7 @@ namespace BreCalClient
this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes); this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes);
this.labelOperationsStart.Content = terminalTimes.OperationsStart.HasValue ? terminalTimes.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelOperationsStart.Content = terminalTimes.OperationsStart.HasValue ? terminalTimes.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTerminalRemarks.Text = terminalTimes.Remarks; this.textBlockTerminalRemarks.Text = terminalTimes.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelOperationsStart.Content = terminalTimes.OperationsEnd.HasValue ? terminalTimes.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelOperationsStart.Content = terminalTimes.OperationsEnd.HasValue ? terminalTimes.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }

View File

@ -48,7 +48,7 @@ namespace BreCalClient
public string? Berth { get; set; } public string? Berth { get; set; }
internal Dictionary<ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new(); internal Dictionary<Extensions.ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new();
public List<Times> Times { get; set; } = new(); public List<Times> Times { get; set; } = new();
@ -56,7 +56,7 @@ namespace BreCalClient
{ {
get get
{ {
Times? agencyTimes = this.GetTimesForParticipantType(ParticipantType.AGENCY); Times? agencyTimes = this.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
if((agencyTimes != null) && (agencyTimes.EtaBerth != null)) if((agencyTimes != null) && (agencyTimes.EtaBerth != null))
return agencyTimes.EtaBerth; return agencyTimes.EtaBerth;
return Shipcall?.Eta; return Shipcall?.Eta;
@ -96,8 +96,7 @@ namespace BreCalClient
get get
{ {
if (this.Shipcall == null) return ""; if (this.Shipcall == null) return "";
Extensions.TypeEnum callType = (Extensions.TypeEnum) this.Shipcall.Type; return string.Format("{0} {1}", this.Shipcall.Type, this.Ship?.Name);
return string.Format("{0} {1}", callType, this.Ship?.Name);
} }
} }
@ -112,12 +111,12 @@ namespace BreCalClient
{ {
foreach (ParticipantAssignment participantAssignment in Shipcall.Participants) foreach (ParticipantAssignment participantAssignment in Shipcall.Participants)
{ {
AssignedParticipants[(ParticipantType)participantAssignment.Type] = participantAssignment; AssignedParticipants[(Extensions.ParticipantType)participantAssignment.Type] = participantAssignment;
} }
} }
} }
internal Times? GetTimesForParticipantType(ParticipantType type) internal Times? GetTimesForParticipantType(Extensions.ParticipantType type)
{ {
if (AssignedParticipants.ContainsKey(type)) { if (AssignedParticipants.ContainsKey(type)) {
@ -127,14 +126,14 @@ namespace BreCalClient
if ((times.ParticipantId == participantId) && (times.ParticipantType == (int) type)) if ((times.ParticipantId == participantId) && (times.ParticipantType == (int) type))
return times; return times;
} }
if(type == ParticipantType.AGENCY) if(type == Extensions.ParticipantType.AGENCY)
{ {
// if I am BSMD and no agency entry was found this means we are editing the agency entry // if I am BSMD and no agency entry was found this means we are editing the agency entry
if(App.Participant.Type == (int) ParticipantType.BSMD) if(App.Participant.Type == (int) Extensions.ParticipantType.BSMD)
{ {
foreach(Times times in this.Times) foreach(Times times in this.Times)
{ {
if ((times.ParticipantId == App.Participant.Id) && (times.ParticipantType == (int) ParticipantType.AGENCY)) if ((times.ParticipantId == App.Participant.Id) && (times.ParticipantType == (int) Extensions.ParticipantType.AGENCY))
return times; return times;
} }
} }
@ -166,7 +165,7 @@ namespace BreCalClient
berthText = berth?.Name; berthText = berth?.Name;
} }
if ((berthText == null) && (times.ParticipantType != ParticipantType.TERMINAL)) if ((berthText == null) && (times.ParticipantType != (int) Extensions.ParticipantType.TERMINAL))
{ {
if (this.Shipcall?.Type == ShipcallType.Arrival) if (this.Shipcall?.Type == ShipcallType.Arrival)
{ {
@ -191,7 +190,7 @@ namespace BreCalClient
/// <param name="_api">API reference to PUT eidted times</param> /// <param name="_api">API reference to PUT eidted times</param>
internal async void UpdateTimesAssignments(DefaultApi _api) internal async void UpdateTimesAssignments(DefaultApi _api)
{ {
foreach (ParticipantType participantType in this.AssignedParticipants.Keys) foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys)
{ {
Times? times = this.GetTimesForParticipantType(participantType); Times? times = this.GetTimesForParticipantType(participantType);
if(times == null) continue; if(times == null) continue;