import groovy.json.*; def input = ''' { "components": { "securitySchemes": { "oAuth2": { "type": "oauth2", "flows": { "clientCredentials": { "tokenUrl": "ht2", } } } }, "schemas": { "carrierBookingReference": { "maxLength": 35, "type": "string", "description": "A set of unique characters provided by carrier to identify a booking.", "example": "ABC709951" }, "transportDocumentReference": { "maxLength": 20, "type": "string", "description": "A unique number allocated by the shipping line to the transport document and the main number used for the tracking of the status of the shipment." }, "transportCallID": { "maxLength": 100, "type": "string", "description": "The unique identifier for a transport call", "example": "123e4567-e89b-12d3-a456-426614174000" }, "vesselIMONumber": { "maxLength": 7, "type": "string", "description": "The unique reference for a registered Vessel. The reference is the International Maritime Organisation (IMO) number, also sometimes known as the Lloyd's register code, which does not change during the lifetime of the vessel", "example": "9321483" }, "carrierVoyageNumber": { "maxLength": 50, "type": "string", "description": "The vessel operator-specific identifier of the Voyage.", "example": "2103S" }, "exportVoyageNumber": { "maxLength": 50, "type": "string", "description": "The vessel operator-specific identifier of the export Voyage.", "example": "2103S" }, "carrierServiceCode": { "maxLength": 5, "type": "string", "description": "The code of the service for which the schedule details are published.", "example": "FE1" }, "UNLocationCode": { "maxLength": 5, "type": "string", "description": "The UN Location code specifying where the place is located.", "example": "FRPAR" }, "equipmentReference": { "maxLength": 15, "type": "string", "description": "The unique identifier for the equipment, which should follow the BIC ISO Container Identification Number where possible. According to ISO 6346, a container identification code consists of a 4-letter prefix and a 7-digit number (composed of a 3-letter owner code, a category identifier, a serial number, and a check-digit). If a container does not comply with ISO 6346, it is suggested to follow Recommendation", "example": "APZU4812090" }, "eventCreatedDateTime": { "type": "string", "description": "The timestamp of when the event was created.\n<b>NB</b>: This field should be considered Metadata", "format": "date-time", "example": "2021-01-09T14:12:56+01:00" }, "transportEvent": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/operationsTransportEvent" }, { "type": "object", "properties": { "documentReferences": { "$ref": "#/components/schemas/documentReferences" } } }, { "$ref": "#/components/schemas/references" } ] }, "transportEventInt": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/operationsTransportEvent" }, { "$ref": "#/components/schemas/carrierSpecificDataInt" }, { "type": "object", "properties": { "documentReferences": { "$ref": "#/components/schemas/documentReferences" } } }, { "$ref": "#/components/schemas/references" } ] }, "operationsTransportEvent": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/baseEvent" }, { "$ref": "#/components/schemas/baseTransportEvent" } ] }, "baseEvent": { "required": [ "eventCreatedDateTime" ], "type": "object", "allOf": [ { "type": "object", "properties": { "eventID": { "$ref": "#/components/schemas/eventID" } } }, { "type": "object", "properties": { "eventCreatedDateTime": { "$ref": "#/components/schemas/eventCreatedDateTime" } } }, { "$ref": "#/components/schemas/baseEventBody" } ] }, "eventID": { "type": "string", "description": "The unique identifier for the event (the message - not the source).\n<b>NB</b>: This field should be considered Metadata", "format": "uuid", "example": "84db923d-2a19-4eb0-beb5-446c1ec57d34" }, "baseEventBody": { "required": [ "eventClassifierCode", "eventDateTime", "eventType" ], "type": "object", "description": "The Event entity is described as a generalization of all the specific event categories. An event always takes place in relation to a shipment and can additionally be linked to a transport or an equipment", "allOf": [ { "type": "object", "properties": { "eventType": { "$ref": "#/components/schemas/eventType" } } }, { "type": "object", "properties": { "eventClassifierCode": { "$ref": "#/components/schemas/eventClassifierCode" } } }, { "type": "object", "properties": { "eventDateTime": { "$ref": "#/components/schemas/eventDateTime" } } }, { "type": "object", "properties": { "carrierSpecificData": { "$ref": "#/components/schemas/carrierSpecificData" } } } ] }, "eventType": { "type": "string", "description": "The Event Type of the object - to be used as a discriminator.\n<b>NB</b>: This field should be considered Metadata" }, "eventClassifierCode": { "type": "string", "description": "Code for the event classifier. Values can vary depending on eventType" }, "eventDateTime": { "type": "string", "description": "The local date and time, where the event took place or when the event will take place, in ISO 8601 format.", "format": "date-time", "example": "2019-11-12T07:41:00+08:30" }, "baseTransportEvent": { "required": [ "transportCall", "transportEventTypeCode" ], "type": "object", "description": "The transport event entity is a specialization of the event entity to support specification of data that only applies to a transport event.", "allOf": [ { "type": "object", "properties": { "eventType": { "type": "string", "example": "TRANSPORT", "enum": [ "TRANSPORT" ] } } }, { "type": "object", "properties": { "eventClassifierCode": { "type": "string", "description": "Code for the event classifier can be - ACT (Actual) - PLN (Planned) - EST (Estimated)", "example": "ACT", "enum": [ "ACT", "PLN", "EST" ] } } }, { "type": "object", "properties": { "transportEventTypeCode": { "$ref": "#/components/schemas/transportEventTypeCode" } } }, { "type": "object", "properties": { "delayReasonCode": { "$ref": "#/components/schemas/delayReasonCode" } } }, { "type": "object", "properties": { "changeRemark": { "$ref": "#/components/schemas/changeRemark" } } }, { "type": "object", "properties": { "transportCall": { "$ref": "#/components/schemas/transportCall" } } } ] }, "transportEventTypeCode": { "type": "string", "description": "Identifier for type of Transport event - ARRI (Arrived) - DEPA (Departed)\nMore details can be found on ", "example": "ARRI", "enum": [ "ARRI", "DEPA" ] }, "delayReasonCode": { "maxLength": 3, "type": "string", "description": "Reason code for the delay. The SMDG-Delay-Reason-Codes are used for this attribute. The code list can be found at ", "example": "WEA" }, "changeRemark": { "maxLength": 250, "type": "string", "description": "Free text information provided by the vessel operator regarding the reasons for the change in schedule and/or plans to mitigate schedule slippage.", "example": "Bad weather" }, "transportCall": { "required": [ "modeOfTransport", "transportCallID" ], "type": "object", "allOf": [ { "type": "object", "properties": { "transportCallID": { "$ref": "#/components/schemas/transportCallID" } } }, { "type": "object", "properties": { "carrierServiceCode": { "$ref": "#/components/schemas/carrierServiceCode" } } }, { "type": "object", "properties": { "carrierVoyageNumber": { "$ref": "#/components/schemas/carrierVoyageNumber" } } }, { "type": "object", "properties": { "carrierVoyageNumber": { "description": "The vessel operator-specific identifier of the Voyage.\nIn case there are multiple voyages the export voyage is chosen.", "deprecated": true } } }, { "type": "object", "properties": { "exportVoyageNumber": { "$ref": "#/components/schemas/exportVoyageNumber" } } }, { "type": "object", "properties": { "importVoyageNumber": { "$ref": "#/components/schemas/importVoyageNumber" } } }, { "type": "object", "properties": { "transportCallSequenceNumber": { "$ref": "#/components/schemas/transportCallSequenceNumber" } } }, { "type": "object", "properties": { "UNLocationCode": { "$ref": "#/components/schemas/UNLocationCode" } } }, { "type": "object", "properties": { "facilityCode": { "$ref": "#/components/schemas/facilityCode" } } }, { "type": "object", "properties": { "facilityCodeListProvider": { "$ref": "#/components/schemas/facilityCodeListProvider" } } }, { "type": "object", "properties": { "facilityTypeCode": { "$ref": "#/components/schemas/facilityTypeCodeTRN" } } }, { "type": "object", "properties": { "otherFacility": { "$ref": "#/components/schemas/otherFacility" } } }, { "type": "object", "properties": { "modeOfTransport": { "$ref": "#/components/schemas/modeOfTransport" } } }, { "type": "object", "properties": { "location": { "allOf": [ { "$ref": "#/components/schemas/location" }, { "type": "object", "description": "Location of the facility. Can often be omitted when it is just repeating the contents of the UNLocationCode field." } ] } } }, { "type": "object", "properties": { "vessel": { "$ref": "#/components/schemas/vessel" } } } ] }, "importVoyageNumber": { "maxLength": 50, "type": "string", "description": "The vessel operator-specific identifier of the import Voyage.", "example": "2103N" }, "transportCallSequenceNumber": { "type": "integer", "description": "Transport operator's key that uniquely identifies each individual call. This key is essential to distinguish between two separate calls at the same location within one voyage.", "example": 2 }, "facilityCode": { "maxLength": 6, "type": "string", "description": "The code used for identifying the specific facility. This code does <b>not</b> include the UN Location Code.", "nullable": false, "example": "ADT" }, "facilityCodeListProvider": { "type": "string", "description": "The provider used for identifying the facility Code", "example": "SMDG", "enum": [ "BIC", "SMDG" ] }, "facilityTypeCodeTRN": { "type": "string", "description": "A specialized version of the facilityCode to be used in TransportCalls. The code to identify the specific type of facility. - BOCR (Border crossing) - CLOC (Customer location) - COFS (Container freight station) - COYA (Deprecated - use OFFD intead) - OFFD (Off dock storage) - DEPO (Depot) - INTE (Inland terminal) - POTE (Port terminal) - RAMP (Ramp)", "example": "POTE", "enum": [ "BOCR", "CLOC", "COFS", "COYA", "OFFD", "DEPO", "INTE", "POTE", "RAMP" ] }, "otherFacility": { "maxLength": 50, "type": "string", "description": "An alternative way to capture the facility when no standardized DCSA facility code can be found.", "example": "Depot location or address" }, "modeOfTransport": { "type": "string", "description": "The mode of transport as defined by DCSA.", "enum": [ "VESSEL", "RAIL", "TRUCK", "BARGE" ] }, "location": { "type": "object", "description": "generally used to capture location-related data, also for locations without UN Location Codes.", "allOf": [ { "type": "object", "properties": { "locationName": { "$ref": "#/components/schemas/locationName" } } }, { "type": "object", "properties": { "latitude": { "$ref": "#/components/schemas/latitude" } } }, { "type": "object", "properties": { "longitude": { "$ref": "#/components/schemas/longitude" } } }, { "type": "object", "properties": { "UNLocationCode": { "$ref": "#/components/schemas/UNLocationCode" } } }, { "type": "object", "properties": { "address": { "description": "Address related information", "allOf": [ { "$ref": "#/components/schemas/address" } ] } } } ] }, "locationName": { "maxLength": 100, "type": "string", "description": "The name of the location.", "example": "Eiffel Tower" }, "latitude": { "maxLength": 10, "type": "string", "description": "Geographic coordinate that specifies the north\u2013south position of a point on the Earth's surface.", "example": "48.8585500" }, "longitude": { "maxLength": 11, "type": "string", "description": "Geographic coordinate that specifies the east\u2013west position of a point on the Earth's surface.", "example": "2.294492036" }, "address": { "type": "object", "description": "An object for storing address related information", "allOf": [ { "type": "object", "properties": { "name": { "$ref": "#/components/schemas/addressName" } } }, { "type": "object", "properties": { "street": { "$ref": "#/components/schemas/streetName" } } }, { "type": "object", "properties": { "streetNumber": { "$ref": "#/components/schemas/streetNumber" } } }, { "type": "object", "properties": { "floor": { "$ref": "#/components/schemas/floor" } } }, { "type": "object", "properties": { "postCode": { "$ref": "#/components/schemas/postCode" } } }, { "type": "object", "properties": { "city": { "$ref": "#/components/schemas/cityName" } } }, { "type": "object", "properties": { "stateRegion": { "$ref": "#/components/schemas/stateRegion" } } }, { "type": "object", "properties": { "country": { "$ref": "#/components/schemas/country" } } } ] }, "addressName": { "maxLength": 100, "type": "string", "description": "Name of the address", "example": "Henrik" }, "streetName": { "maxLength": 100, "type": "string", "description": "The name of the street of the party\u2019s address.", "example": "Kronprincessegade" }, "streetNumber": { "maxLength": 50, "type": "string", "description": "The number of the street of the party\u2019s address.", "example": "54" }, "floor": { "maxLength": 50, "type": "string", "description": "The floor of the party\u2019s street number.", "example": "5. sal" }, "postCode": { "maxLength": 10, "type": "string", "description": "The post code of the party\u2019s address.", "example": "1306" }, "cityName": { "maxLength": 65, "type": "string", "description": "The city name of the party\u2019s address.", "example": "K\u00f8benhavn" }, "stateRegion": { "maxLength": 65, "type": "string", "description": "The state/region of the party\u2019s address.", "example": "N/A" }, "country": { "maxLength": 75, "type": "string", "description": "The country of the party\u2019s address.", "example": "Denmark" }, "vessel": { "required": [ "vesselIMONumber" ], "type": "object", "description": "describes a floating, sea going structure (mother vessels and feeder vessels) with either an internal or external mode of propulsion designed for the transport of cargo and/or passengers. Ocean vessels are uniquely identified by an IMO number consisting of 7 digits, or alternatively by their AIS signal with an MMSI number. \n", "allOf": [ { "type": "object", "properties": { "vesselIMONumber": { "$ref": "#/components/schemas/vesselIMONumber" } } }, { "type": "object", "properties": { "vesselName": { "$ref": "#/components/schemas/vesselName" } } }, { "type": "object", "properties": { "vesselFlag": { "$ref": "#/components/schemas/vesselFlag" } } }, { "type": "object", "properties": { "vesselCallSignNumber": { "$ref": "#/components/schemas/vesselCallSignNumber" } } }, { "type": "object", "properties": { "vesselOperatorCarrierCode": { "$ref": "#/components/schemas/vesselOperatorCarrierCode" } } }, { "type": "object", "properties": { "vesselOperatorCarrierCodeListProvider": { "$ref": "#/components/schemas/vesselOperatorCarrierCodeListProvider" } } } ] }, "vesselName": { "maxLength": 35, "type": "string", "description": "The name of the Vessel given by the Vessel Operator and registered with IMO.", "example": "King of the Seas" }, "vesselFlag": { "maxLength": 2, "type": "string", "description": "The flag of the nation whose laws the vessel is registered under. This is the ISO 3166 two-letter country code", "example": "DE" }, "vesselCallSignNumber": { "maxLength": 10, "type": "string", "description": "A unique alphanumeric identity that belongs to the vessel and is assigned by the International Telecommunication Union (ITU). It consists of a threeletter alphanumeric prefix that indicates nationality, followed by one to four characters to identify the individual vessel. For instance, vessels registered under Denmark are assigned the prefix ranges 5PA-5QZ, OUAOZZ, and XPA-XPZ. The Call Sign changes whenever a vessel changes its flag.", "example": "NCVV" }, "vesselOperatorCarrierCode": { "maxLength": 10, "type": "string", "description": "The carrier who is in charge of the vessel operation based on either the SMDG or SCAC code lists", "nullable": false, "example": "MAEU" }, "vesselOperatorCarrierCodeListProvider": { "type": "string", "description": "Identifies the code list provider used for the operator and partner carriercodes.", "nullable": false, "example": "NMFTA", "enum": [ "SMDG", "NMFTA" ] }, "documentReferences": { "type": "array", "description": "An optional list of key-value (documentReferenceType-documentReferenceValue) pairs representing links to objects relevant to the event. The <b>documentReferenceType</b>-field is used to describe where the <b>documentReferenceValue</b>-field is pointing to.", "example": [ { "documentReferenceType": "BKG", "documentReferenceValue": "ABC123123123" }, { "documentReferenceType": "TRD", "documentReferenceValue": "85943567-eedb-98d3-f4ed-aed697474ed4" } ], "items": { "$ref": "#/components/schemas/documentReferences_inner" } }, "references": { "type": "object", "properties": { "references": { "type": "array", "items": { "$ref": "#/components/schemas/reference" } } } }, "reference": { "required": [ "referenceType", "referenceValue" ], "type": "object", "description": "references provided by the shipper or freight forwarder at the time of booking or at the time of providing shipping instruction. Carriers share it back when providing track and trace event updates, some are also printed on the B/L. Customers can use these references to track shipments in their internal systems.", "allOf": [ { "type": "object", "properties": { "referenceType": { "$ref": "#/components/schemas/referenceType" } } }, { "type": "object", "properties": { "referenceValue": { "$ref": "#/components/schemas/referenceValue" } } } ] }, "referenceType": { "type": "string", "description": "The reference type codes defined by DCSA. - FF (Freight Forwarder\u2019s Reference) - SI (Shipper\u2019s Reference) - PO (Purchase Order Reference) - CR (Customer\u2019s Reference) - AAO (Consignee\u2019s Reference) - EQ (Equipment Reference)", "example": "FF", "enum": [ "FF", "SI", "PO", "CR", "AAO", "EQ" ] }, "referenceValue": { "maxLength": 100, "type": "string", "description": "The actual value of the reference." }, "shipmentEvent": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/baseEvent" }, { "$ref": "#/components/schemas/baseShipmentEvent" } ] }, "shipmentEventInt": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/baseEvent" }, { "$ref": "#/components/schemas/baseShipmentEvent" }, { "$ref": "#/components/schemas/carrierSpecificDataInt" } ] }, "baseShipmentEvent": { "required": [ "documentID", "documentTypeCode", "shipmentEventTypeCode" ], "type": "object", "description": "The shipment event entity is a specialization of the event entity to support specification of data that only applies to a shipment event.", "allOf": [ { "type": "object", "properties": { "eventType": { "type": "string", "example": "SHIPMENT", "enum": [ "SHIPMENT" ] } } }, { "type": "object", "properties": { "eventDateTime": { "description": "Value for eventDateTime must be the same value as eventCreatedDateTime" } } }, { "type": "object", "properties": { "eventClassifierCode": { "type": "string", "description": "Code for the event classifier can be - ACT (Actual) - PLN (Planned) - EST (Estimated)", "example": "ACT", "enum": [ "ACT", "PLN", "EST" ] } } }, { "type": "object", "properties": { "shipmentEventTypeCode": { "$ref": "#/components/schemas/shipmentEventTypeCode" } } }, { "type": "object", "properties": { "documentID": { "$ref": "#/components/schemas/documentID" } } }, { "type": "object", "properties": { "documentTypeCode": { "$ref": "#/components/schemas/documentTypeCode" } } }, { "type": "object", "properties": { "reason": { "$ref": "#/components/schemas/reason" } } }, { "type": "object", "properties": { "shipmentID": { "$ref": "#/components/schemas/shipmentID" } } }, { "$ref": "#/components/schemas/references" } ] }, "shipmentEventTypeCode": { "type": "string", "description": "The status of the document in the process. Possible values are - RECE (Received) - DRFT (Drafted) - PENA (Pending Approval) - PENU (Pending Update) - REJE (Rejected) - APPR (Approved) - ISSU (Issued) - SURR (Surrendered) - SUBM (Submitted) - VOID (Void) - CONF (Confirmed) - REQS (Requested) - CMPL (Completed) - HOLD (On Hold) - RELS (Released)\nMore details can be found on ", "example": "DRFT", "enum": [ "RECE", "DRFT", "PENA", "PENU", "REJE", "APPR", "ISSU", "SURR", "SUBM", "VOID", "CONF", "REQS", "CMPL", "HOLD", "RELS" ] }, "documentID": { "type": "string", "description": "The id of the object defined by the documentTypeCode.", "example": "the-id-of-the-documentTypeCode" }, "documentTypeCode": { "maxLength": 3, "type": "string", "description": "The code to identify the type of information documentID points to. Can be one of the following values - CBR (Carrier Booking Request Reference) - BKG (Booking) - SHI (Shipping Instruction) - SRM (Shipment Release Message) - TRD (Transport Document) - ARN (Arrival Notice) - VGM (Verified Gross Mass) - CAS (Cargo Survey) - CUS (Customs Inspection) - DGD (Dangerous Goods Declaration) - OOG (Out of Gauge)\nMore details can be found on ", "example": "SHI", "enum": [ "CBR", "BKG", "SHI", "SRM", "TRD", "ARN", "VGM", "CAS", "CUS", "DGD", "OOG" ] }, "reason": { "type": "string", "description": "Reason field in a Shipment event. This field can be used to explain why a specific event has been sent.", "example": "The following attributes are missing..." }, "shipmentID": { "type": "string", "description": "The identifier for a shipment", "format": "uuid", "example": "d9c69bc8-294d-46d1-807c-654598341374" }, "equipmentEvent": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/baseEvent" }, { "$ref": "#/components/schemas/baseEquipmentEvent" } ] }, "equipmentEventInt": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/baseEvent" }, { "$ref": "#/components/schemas/baseEquipmentEvent" }, { "$ref": "#/components/schemas/carrierSpecificDataInt" } ] }, "baseEquipmentEvent": { "required": [ "emptyIndicatorCode", "equipmentEventTypeCode" ], "type": "object", "description": "The equipment event entity is a specializationshemas of the event entity to support specification of data that only applies to an equipment event.", "allOf": [ { "type": "object", "properties": { "eventType": { "type": "string", "example": "EQUIPMENT", "enum": [ "EQUIPMENT" ] } } }, { "type": "object", "properties": { "eventClassifierCode": { "type": "string", "description": "Code for the event classifier can be - PLN (Planned) - ACT (Actual) - EST (Estimated)", "example": "EST", "enum": [ "PLN", "ACT", "EST" ] } } }, { "type": "object", "properties": { "equipmentEventTypeCode": { "$ref": "#/components/schemas/equipmentEventTypeCode" } } }, { "type": "object", "properties": { "equipmentReference": { "$ref": "#/components/schemas/equipmentReference" } } }, { "type": "object", "properties": { "ISOEquipmentCode": { "$ref": "#/components/schemas/ISOEquipmentCode" } } }, { "type": "object", "properties": { "emptyIndicatorCode": { "$ref": "#/components/schemas/emptyIndicatorCode" } } }, { "type": "object", "properties": { "eventLocation": { "$ref": "#/components/schemas/location" } } }, { "type": "object", "properties": { "transportCall": { "$ref": "#/components/schemas/transportCall" } } }, { "type": "object", "properties": { "documentReferences": { "$ref": "#/components/schemas/documentReferences" } } }, { "$ref": "#/components/schemas/references" }, { "$ref": "#/components/schemas/seals" } ] }, "equipmentEventTypeCode": { "type": "string", "description": "Unique identifier for equipmentEventTypeCode. - LOAD (Loaded) - DISC (Discharged) - GTIN (Gated in) - GTOT (Gated out) - STUF (Stuffed) - STRP (Stripped) - PICK (Pick-up) - DROP (Drop-off) - INSP (Inspected) - RSEA (Resealed) - RMVD (Removed)\nMore details can be found on ,", "example": "LOAD", "enum": [ "LOAD", "DISC", "GTIN", "GTOT", "STUF", "STRP", "PICK", "DROP", "INSP", "RSEA", "RMVD" ] }, "ISOEquipmentCode": { "maxLength": 4, "type": "string", "description": "Unique code for the different equipment size/type used for transporting commodities. The code is a concatenation of ISO Equipment Size Code and ISO Equipment Type Code A and follows the ISO 6346 standard.", "example": "22GP" }, "emptyIndicatorCode": { "type": "string", "description": "Code to denote whether the equipment is empty or laden.", "example": "EMPTY", "enum": [ "EMPTY", "LADEN" ] }, "seals": { "type": "object", "properties": { "seals": { "type": "array", "items": { "$ref": "#/components/schemas/seal" } } } }, "seal": { "required": [ "sealNumber", "sealType" ], "type": "object", "description": "addresses the seal-related information associated with the shipment equipment. A seal is put on a shipment equipment once it is loaded. This seal is meant to stay on until the shipment equipment reaches its final destination.", "allOf": [ { "type": "object", "properties": { "sealNumber": { "$ref": "#/components/schemas/sealNumber" } } }, { "type": "object", "properties": { "sealSource": { "$ref": "#/components/schemas/sealSource" } } }, { "type": "object", "properties": { "sealType": { "$ref": "#/components/schemas/sealType" } } } ] }, "sealNumber": { "maxLength": 15, "type": "string", "description": "Identifies a seal affixed to the container." }, "sealSource": { "type": "string", "description": "The source of the seal, namely who has affixed the seal. This attribute links to the Seal Source ID defined in the Seal Source reference data entity. - CAR (Carrier) - SHI (Shipper) - PHY (Phytosanitary) - VET (Veterinary) - CUS (Customs)", "example": "CUS", "enum": [ "CAR", "SHI", "PHY", "VET", "CUS" ] }, "sealType": { "type": "string", "description": "The type of seal. This attribute links to the Seal Type ID defined in the Seal Type reference data entity. - KLP (Keyless padlock) - BLT (Bolt) - WIR (Wire)", "example": "WIR", "enum": [ "KLP", "BLT", "WIR" ] }, "error": { "required": [ "errorDateTime", "errors", "httpMethod", "requestUri", "statusCode", "statusCodeText" ], "type": "object", "properties": { "httpMethod": { "type": "string", "description": "The HTTP request method type", "example": "POST" }, "requestUri": { "type": "string", "description": "The request URI.", "example": "ht" }, "errors": { "$ref": "#/components/schemas/subErrors" }, "statusCode": { "type": "integer", "description": "The HTTP status code", "example": 400 }, "statusCodeText": { "type": "string", "description": "The textual representation of the response status.", "example": "Bad Request" }, "errorDateTime": { "type": "string", "description": "The date and time (in ISO 8601 format) the error occurred.", "format": "$date-time", "example": "2019-11-12T07:41:00+08:30" } } }, "subErrors": { "type": "array", "items": { "$ref": "#/components/schemas/subErrors_inner" } }, "inline_response_default": { "allOf": [ { "$ref": "#/components/schemas/error" }, { "type": "object", "properties": { "httpMethod": { "example": "GET" } } }, { "type": "object", "properties": { "requestUri": { "example": "hts" } } } ] }, "documentReferences_inner": { "type": "object", "properties": { "documentReferenceType": { "type": "string", "description": "Describes where the documentReferenceValue is pointing to", "example": "BKG", "enum": [ "BKG (Booking)", "TRD (Transport Document)" ] }, "documentReferenceValue": { "type": "string", "description": "The value of the identifier the documentReferenceType is describing", "example": "123e4567-e89b-12d3-a456-426614174000" } } }, "carrierSpecificData": { "type": "object", "properties": { "internalEventCode": { "type": "string", "description": "CMA internal event Code", "example": "XOF" }, "internalEventLabel": { "type": "string", "description": "CMA internal event Label", "example": "Load on Board" }, "internalLocationCode": { "type": "string", "description": "CMA internal location Code", "example": "FRMRS" }, "internalFacilityCode": { "type": "string", "description": "CMA internal facility Code", "example": "FRMRSD2DT" }, "bookingExportVoyageReference": { "type": "string", "description": "Carrier export voyage reference defined on Booking", "example": "NR145F8MA" }, "transportationPhase": { "type": "string", "description": "The Transportation phase, Export, Transshipent or Import", "example": "Export" }, "shipmentLocationType": { "type": "string", "description": "The location type for the shipment", "example": "POL" }, "transportCallSequenceTotal": { "type": "integer", "description": "The total number of sequences (transportCallSequenceNumber) provided in transportation plan", "example": 2 }, "numberOfUnits": { "type": "integer", "description": "The total number equipment units concerned by the message", "example": 1 }, "customsReferences": { "type": "array", "items": { "$ref": "#/components/schemas/CustomsReferences" } }, "originBookingReference": { "$ref": "#/components/schemas/shipmentID" }, "splitToBookingReferences": { "type": "array", "items": { "$ref": "#/components/schemas/shipmentID" } }, "mergeToBookingReference": { "$ref": "#/components/schemas/shipmentID" }, "masterPartLoadBookingReference": { "$ref": "#/components/schemas/shipmentID" }, "partLoadGroupBookingReferences": { "type": "array", "items": { "$ref": "#/components/schemas/shipmentID" } } } }, "carrierSpecificDataInt": { "type": "object", "properties": { "carrierSpecificData": { "$ref": "#/components/schemas/CarrierSpecificDataIntInf" } } }, "CarrierSpecificDataIntInf": { "type": "object", "properties": { "internalMoveCode": { "type": "string", "description": "CMA internal move Code", "example": "MED" }, "internalMoveLabel": { "type": "string", "description": "CMA internal move Label", "example": "Returned Damaged" } } }, "CustomsReferences": { "type": "object", "properties": { "equipmentReference": { "$ref": "#/components/schemas/equipmentReference" }, "customsReference": { "type": "string", "description": "the customs reference for the container", "example": "ATB12345687493994" }, "referenceDate": { "type": "string", "format": "date", "description": "the customs reference date", "example": "2022-05-01" } } }, "subErrors_inner": { "required": [ "message", "reason" ], "type": "object", "properties": { "reason": { "type": "string", "description": "High level error message.", "example": "invalidQuery" }, "message": { "type": "string", "description": "Detailed error message.", "example": "The request did not contain one of the three required query parameters." } } } }, "headers": { "API-Version": { "description": "SemVer used to indicate the version of the contract (API version) returned.", "schema": { "type": "string", "example": "2.2.0" } }, "Current-Page": { "description": "A link to the current page.", "required": true, "schema": { "type": "string", "example": "fE9mZnNldHw9MCZsaW1pdD01" } }, "Next-Page": { "description": "A link to the next page. Next-Page header link MAY be omitted if the current page is the last page.", "required": false, "schema": { "type": "string", "example": "fE9mZnNldHw9NSZsaW1pdD01" } }, "Prev-Page": { "description": "A link to the previous page. Previous-Page header link MAY be omitted if the current page is the first page.", "required": false, "schema": { "type": "string", "example": "fE9mZnNldHw9MCZsaW1pdD01" } }, "Last-Page": { "description": "A link to the last page. Last-Page header link MAY be omitted if the current page is the last page.", "required": false, "schema": { "type": "string", "example": "fE9mZnNldHw9NTkmbGltaXQ9NQ==" } }, "First-Page": { "description": "A link to thefirst page. First-Page header link MAY be omitted if current page is the first page.", "required": false, "schema": { "type": "string", "example": "fE9mZnNldHw9NjAmbGltaXQ9NQ==" } } } } } '''; def contents = new groovy.json.JsonSlurper().parseText(input) String concatenate(String k, String v) { "${k}-${v}" } def flattenMap(Map map) { map.collectEntries { k, v -> v instanceof Map ? flattenMap(v).collectEntries { k1, v1 -> key = concatenate(k,k1) [ (key): v1 ] } : [ (k): v ] } } def tableDicoBuilder(contents) { flat_contents= flattenMap(contents) flat_contents_keys = flat_contents.keySet() tableDico=[:] for ( key in flat_contents_keys ) { keytolist = key.split('-') //a if ( keytolist.contains("properties") & keytolist.contains('$ref') ) { cols=[:] ind_p = keytolist.findIndexValues { it == "properties"}.collect { it as Integer } ind_r = keytolist.findIndexValues { it == '$ref'}.collect { it as Integer } table_index = ind_p[0]-1 col_index = ind_p[0]+1 ref = flat_contents[key] ref = ref.split('/') //// sub_col = ref[-1] table = keytolist[table_index] col = keytolist[col_index] /// path = keytolist[0 .. ind_p[0]-2] path = path.join('-') path_to_subcol_desc = path+'-'+sub_col+'-description' path_to_subcol_type = path+'-'+sub_col+'-type' subcol_desc = "" subcol_type="" if (flat_contents[path_to_subcol_desc] != null ) { tmp_subcol_desc = flat_contents[path_to_subcol_desc].replaceAll("(\r\n|\r|\n|\n\r)", "\\\\n") subcol_desc = tmp_subcol_desc.replaceAll('"', '\\\\"') } if (flat_contents[path_to_subcol_type] != null ) {subcol_type = flat_contents[path_to_subcol_type]} cols[col+"."+sub_col]= [subcol_desc,subcol_type] if ( table in tableDico.keySet() ) {tableDico[table] = tableDico[table] + cols} else (tableDico[table] = cols ) } else if ( keytolist.contains("properties") & keytolist.contains("type") ) { ks = key.replaceAll( "type", "description") if (ks in flat_contents_keys) { def ind = keytolist.findIndexValues { it == "properties"}.collect { it as Integer } if ( ind.size() == 1 ) cols=[:] table_index = ind[0]-1 col_index = ind[0]+1 type_index = keytolist.join('-') table = keytolist[table_index] col = keytolist[col_index] tmp_colDesc = flat_contents[ks].replaceAll("(\r\n|\r|\n|\n\r)", "\\\\n") colDesc = tmp_colDesc.replaceAll('"', '\\\\"') colType = flat_contents[type_index] cols[col]= [colDesc,colType] if ( table in tableDico.keySet() ) {tableDico[table] = tableDico[table] + cols} else (tableDico[table] = cols ) } } else if ( keytolist.contains("allOf") ) { cols=[:] ind_allof = keytolist.findIndexValues { it == "allOf"}.collect { it as Integer } table_index = ind_allof[0]-1 table = keytolist[table_index] allof = flat_contents[key] for (item in allof) { item_flat = flattenMap(item) keys = item_flat.keySet() for (k in keys) { kl = k.split('-') if (kl.contains('$ref') ) { ref = item_flat[k] ref = ref.split('/') col = ref[-1] path = keytolist[0 .. ind_allof[0]-2] path = path.join('-') path_to_col_desc = path+'-'+col+'-description' path_to_col_type = path+'-'+col+'-type' col_desc = "" col_type="" if (flat_contents[path_to_col_desc] != null ) { tmp_col_desc = flat_contents[path_to_col_desc].replaceAll("(\r\n|\r|\n|\n\r)", "\\\\n") col_desc = tmp_col_desc.replaceAll('"', '\\\\"') } if (flat_contents[path_to_col_type] != null ) {col_type = flat_contents[path_to_col_type]} cols[col]= [col_desc,col_type] if ( table in tableDico.keySet() ) {tableDico[table] = tableDico[table] + cols} else (tableDico[table] = cols ) } else if (kl.contains("properties") & kl.contains("description") ) { cols=[:] ks = k.replaceAll( "description" , "type") ind_allof = kl.findIndexValues { it == "properties"}.collect { it as Integer } col_index = ind_allof[0]+1 col = kl[col_index] tmp_colDesc = item_flat[k].replaceAll("(\r\n|\r|\n|\n\r)", "\\\\n") colDesc = tmp_colDesc.replaceAll('"', '\\\\"') colType = item_flat[ks] cols[col]= [colDesc,colType] if ( table in tableDico.keySet() ) {tableDico[table] = tableDico[table] + cols} else (tableDico[table] = cols ) } } } } } return tableDico } def statusUpdate(assetName) { return "candidate" } def resBuilder(resName,resExtID, description) { statusName = statusUpdate("apiTechnicalName" + "/" + resName) // Replace null values for description if (!description) { description = "" } output= '''{ "resourceType": "Asset", "identifier": { "extSystemId": "''' + "extSystemId" + '''", "extEntityId" : "''' + "apiTechnicalName" + resExtID + '''" }, "domain": { "id": "''' + "domainId" + '''" }, "name": "''' + "apiTechnicalName" + resExtID + '''", "displayName": "''' + resName + '''", "type": { "name": "API Endpoint" }, "status": { "name": "''' + "statusName" + '''" }, "tags" : ["API"], "attributes": { "Definition" : [{ "value": "''' + "description" + '''" }] }, "relations": { "''' + "relApiApiRes" + '''": [{ "extSystemId": "''' + "extSystemId" + '''", "extEntityId": "''' + "apiTechnicalName" + '''" }] } }''' return output } println(tableDicoBuilder(contents)) tableDico = tableDicoBuilder(contents) resDico= ["[GET] /events":["resDesc":"Returns all events filtered by the queryParameters.\n<b>NB</b>: It is possible to combine queryParameters. When combining queryParameters be aware that it is also possible to make combinations that are mutual contradicting.\nExample: <i>shipmentEventTypeCode=DRFT and equipmentEventTypeCode=GTIN</i>\nSince there is no event that can be a ShipmentEvent <u>and</u> an EquipmentEvent at the same time <b>this will return an empty list</b>!\n<b>Follow DCSA TNT 2.2.0 specifications</b>", "resExtID":"/events/searchMoveOnCommercialCycle"], "[GET] /events/{trackingReference}":["resDesc":"Return commercial cycle belonging to provided tracking reference\n<b>Return data follow DCSA TNT 2.2.0 specifications</b>", "resExtID":"/events/{trackingReference}/getMoveOnCommercialCycle"], "[GET] /partners/{applicativePartnerCode}/events":["resDesc":"Returns all events filtered by the queryParameters.\n<b>NB</b>: It is possible to combine queryParameters. When combining queryParameters be aware that it is also possible to make combinations that are mutual contradicting.\nExample: <i>shipmentEventTypeCode=DRFT and equipmentEventTypeCode=GTIN</i>\nSince there is no event that can be a ShipmentEvent <u>and</u> an EquipmentEvent at the same time <b>this will return an empty list</b>!\n<b>Follow DCSA TNT 2.2.0 specifications</b>","resExtID":"/partners/{applicativePartnerCode}/events/searchMoveOnCommercialCyclewithApp"], "[GET] /partners/{applicativePartnerCode}/events/{trackingReference}":["resDesc":"Return commercial cycle belonging to provided tracking reference\n<b>Return data follow DCSA TNT 2.2.0 specifications</b>", "resExtID":"/partners/{applicativePartnerCode}/events/{trackingReference}/getMoveOnCommercialCycleWithApp"], "[GET] /advanced/events":["resDesc":"Returns all events filtered by the queryParameters.\n<b>NB</b>: It is possible to combine queryParameters. When combining queryParameters be aware that it is also possible to make combinations that are mutual contradicting.\nExample: <i>shipmentEventTypeCode=DRFT and equipmentEventTypeCode=GTIN</i>\nSince there is no event that can be a ShipmentEvent <u>and</u> an EquipmentEvent at the same time <b>this will return an empty list</b>!", "resExtID":"/advanced/events/searchAdvancedMoveOnCommercialCycle"], "[GET] /advanced/events/{trackingReference}":["resDesc":"Return allevents of commercial cycle belonging to provided tracking reference\n<b>Return data follow DCSA TNT 2.2.0 specifications</b>","resExtID":"/advanced/events/{trackingReference}/getAdvancedMoveOnCommercialCycle"]] class Account { String id BigDecimal value Date createdAt } Account account = new Account( id: '123', value: 15.6 ) def json = JsonOutput.toJson(account) tabUnique = [] colUnique = [] tag = "" // Building API ressource dictionary for (resResponse in resDico) { res = resResponse.key resVal = resResponse.value println("[" + "currentWorkflowProcessId" + "] Endpoint name : " + res) println("[" + "currentWorkflowProcessId" + "] Endpoint value: " + resVal.toString()) println("[" + "currentWorkflowProcessId" + "] Endpoint external ID >" + resVal['resExtID'] + " Endpoint name" + res) json.add(resBuilder(res,resVal['resExtID'],resVal['resDesc'])) // Feeding tables & columns for (table in resVal['resTable']) { //loggerApi.info("table " + table) if(table in tabUnique) { //loggerApi.info('resValTable' + table) tag = "" } else { tag = "API" tabUnique.add(table) } json.add(tableBuilder(res,table,resVal['resExtID'],domainId,statusName,tag)) tabDetails=tableDico[table] loggerApi.info("****************tabDetail: " + tabDetails ) for (colResponse in tabDetails) { col = colResponse.key desc = colResponse.value if (col!='nocol') { if(table+col in colUnique){ tag="" //loggerApi.info("[" + currentWorkflowProcessId + "] ALERT " + col) } else { tag="API" //oggerApi.info("ColUnique") colUnique.add(table+col) } //loggerApi.info("[" + currentWorkflowProcessId + "] ColumnBuilder") json.add(columnBuilder(col,table,res,domainId,statusName, desc[1],desc[0],tag)) } } } }
Write, Run & Share Groovy code online using OneCompiler's Groovy online compiler for free. It's one of the robust, feature-rich online compilers for Groovy language, running the latest Groovy version 2.6. Getting started with the OneCompiler's Groovy editor is easy and fast. The editor shows sample boilerplate code when you choose language as Groovy and start coding.
OneCompiler's Groovy online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Groovy program which takes name as input and prints hello message with your name.
def name = System.in.newReader().readLine()
println "Hello " + name
Groovy is an object-oriented programming language based on java. Apache Groovy is a dynamic and agile language which is similar to Python, Ruby, Smalltalk etc.
Data type | Description | Range |
---|---|---|
String | To represent text literals | NA |
char | To represent single character literal | NA |
int | To represent whole numbers | -2,147,483,648 to 2,147,483,647 |
short | To represent short numbers | -32,768 to 32,767 |
long | To represent long numbers | -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 |
double | To represent 64 bit floating point numbers | 4.94065645841246544e-324d to 1.79769313486231570e+308d |
float | To represent 32 bit floating point numbers | 1.40129846432481707e-45 to 3.40282346638528860e+38 |
byte | To represent byte value | -128 to 127 |
boolean | To represent boolean values either true or false | True or False |
You can define variables in two ways
data-type variable-name;
[or]
def variable-name;
0.upto(n) {println "$it"}
or
n.times{println "$it"}
where n is the number of loops and 0 specifies the starting index
When ever you want to perform a set of operations based on a condition or set of conditions, then If / Nested-If / If-Else is used.
if(conditional-expression) {
// code
} else {
// code
}
Switch is an alternative to If-Else-If ladder and to select one among many blocks of code.
switch(conditional-expression) {
case value1:
// code
break; // optional
case value2:
// code
break; // optional
...
default:
//code to be executed when all the above cases are not matched;
}
List allows you to store ordered collection of data values.
def mylist = [1,2,3,4,5];
List Methods | Description |
---|---|
size() | To find size of elements |
sort() | To sort the elements |
add() | To append new value at the end |
contains() | Returns true if this List contains requested value. |
get() | Returns the element of the list at the definite position |
pop() | To remove the last item from the List |
isEmpty() | Returns true if List contains no elements |
minus() | This allows you to exclude few specified elements from the elements of the original |
plus() | This allows you to add few specified elements to the elements of the original |
remove() | To remove the element present at the specific position |
reverse() | To reverse the elements of the original List and creates new list |