Handle with care: regex in machine readable spec versus ApiDoc

Questions refering to the Optiflow based API within PTV Developer (launched on 20.12.2023)
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 2929
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Handle with care: regex in machine readable spec versus ApiDoc

Post by Bernd Welter »

I just crashed into this error message and from my perspective you should at least be aware of the underlying concept.
This is not a bug.

Code: Select all

{
  { "traceId": "...",
    "description": "The validation of the request failed. Details can be found in **causes**.",
    "errorCode": "GENERAL_VALIDATION_ERROR",
    "causes": [
      { "description": "The value of a string parameter does not satisfy the required pattern.",
        "errorCode": "GENERAL_PATTERN_VIOLATED",
        "parameter": "$.metadata.tags[1]",
        "details": { "pattern": "^[a-zA-Z0-9_-]{1,36}$" }
      }
    ],
    "details": {}
  }
Now here's what caused this error : my metadata tags have been set to this. Look at the second tag which is set to "pOrders:0".

Code: Select all

  "metadata": {
    "name": "Dummy Bernd Welter",
    "tags": [
      "locations-200",
      "pOrders:0",
      "dOrders-199",
      "pdOrders-",
      "vehicles-1"
    ]
  }
metadata.tags.png
The human readable API doc shows the necessity of the regex for the name. But not for the tags.
The human readable API doc shows the necessity of the regex for the name. But not for the tags.
In the machine readable spec the regex is documented for both name and tags:

Code: Select all

     "OptimizationRequestMetadata": {
        "description": "User-defined request metadata that does not influence the optimization but is returned in the result.",
        "type": "object",
        "properties": {
          "name": {
            "description": "The name of the optimization.",
            "maxLength": 100, "minLength": 1,
            "pattern": "^[a-zA-Z0-9_ -]{1,100}$", "type": "string"
          },
          "tags": {
            "description": "A list of tags of the optimization.",
            "maxItems": 5,
            "type": "array",
            "items": {
              "maxLength": 36, "minLength": 1,
              "pattern": "^[a-zA-Z0-9_-]{1,36}$", "type": "string"
            }}}}
Best regards,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply