Skip to content

Abbreviated form "both" in dtr-test not supported #77

Description

@Pfeil

I understand if you do not plan to support each feature of the older test DTR, but I thought I'd report this just to make sure you are aware of this. I am also not even sure if JSON Schema can do this. I set the property of this type to "both" in order to make sure we are backwards compatible, but it seems this is being considered a "yes" instead. I am not sure if I misconfigured the type at some point, maybe I did? The issue (assuming the issue it not the type) can be reproduced quickly using this curl command:

curl -X 'GET' \
  'https://typeapi.lab.pidconsortium.net/v1/types/schema/21.T11148/2f314c8fe5fb6a0063a8' \
  -H 'accept: application/json'

And the result only accepts a string:

{
  "type": "string",
  "pattern": "^http(s)?:(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$",
  "description": "URL referring to a license. E.g. https://www.apache.org/licenses/LICENSE-2.0, https://creativecommons.org/licenses/by-nd/4.0/legalcode",
  "title": "Validation schema for type 'licenseURL' with the PID '21.T11148/2f314c8fe5fb6a0063a8'",
  "$schema": "http://json-schema.org/draft-04/schema#"
}

I think the schema could / should look similar to this:

{
  "oneOf": [
        {
            "type": "string",
            "pattern": "^http(s)?:(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"
        },
        {
            "type": "object",
          	"properties": {
             	"licenseURL": {
                    "type": "string",
                    "pattern": "^http(s)?:(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"
                },
            },
          	"required": [ "licenseURL" ]
        }
    ],
  "description": "URL referring to a license. E.g. https://www.apache.org/licenses/LICENSE-2.0, https://creativecommons.org/licenses/by-nd/4.0/legalcode",
  "title": "Validation schema for type 'licenseURL' with the PID '21.T11148/2f314c8fe5fb6a0063a8'",
  "$schema": "http://json-schema.org/draft-04/schema#"
}

I also added the proposed schema to the type, and it seems to work for me (we use the legacy schemas as a fallback and require any schema to validate the value).

I did not test if the new DTR is affected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions