question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The mutually-exclusive url and identifier properties of License object are optional in specification and required in schema

See original GitHub issue

In the definition of the License object of OpenAPI 3.1: the url and identifier properties are not marked as REQUIRED, so optional, and are defined as mutually exclusive.

The schema of the License object does not match with the specification making url or identifier required using the following construction at the root of of the object definition:

"oneOf": [
  {"required": ["identifier"] },
  {"required": ["url"]}
]

If we compare both behaviors, that means the following (note that name is required):

SpecificationSchema
  • We can have
    • name alone
    • name and url
    • name and identifier
  • But we can't have
    • name, url and identifier
  • We can have
    • name alone
    • name and url
    • name and identifier
  • But we can't have
    • name alone
    • name, url and identifier
  • The following document which is valid according to the specification is considered invalid when using the schema with the validation script or directly using it with ajv:

    openapi: 3.1.0
    info:
      title: Dummy Bookshop
      version: '1.0'
      license:
        name: Apache 2.0
    paths: {}
    

    Before proposing a pull request to fix that issue, I would like to confirm that my interpretation of the specification is correct and to know if there are any recommendations to follow regarding when modifying the schema. Besides sticking to the JSON Schema version already used, there are maybe some features to not use to ensure compatibility? (I already found 4 different ways to say “url and identifier are optional and mutually exclusive”, I’ll put them in the discussion if fixing the schema is the solution).

    Issue Analytics

    • State:closed
    • Created a year ago
    • Comments:11 (10 by maintainers)

    github_iconTop GitHub Comments

    1reaction
    webroncommented, Jul 25, 2022

    There’s a brief explanation at the schema directory (version based), for example https://github.com/OAI/OpenAPI-Specification/tree/main/schemas/v3.1.

    You only need to modify the YAML version, no need to update the date and the PR should be against the main branch.

    1reaction
    arno-di-loretocommented, Jul 25, 2022

    🤦🏻‍♂️😅 Obviously “if A not B” also means “if B not A”. I really like the dependentSchemas option, let’s go for this one.

    dependentSchemas:
      identifier:
        not:
          required:
            - url
    
    Read more comments on GitHub >

    github_iconTop Results From Across the Web

    What is the info property in OpenAPI? - API Handyman
    This new identifier property is optional but mutually exclusive with the url one. No information were found in the specification, issues or pull ......
    Read more >
    OpenAPI Specification - Version 3.0.3 - Swagger
    3. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this ...
    Read more >
    spec/spec.md at master · open-rpc/spec · GitHub
    In the following description, if a field is not explicitly REQUIRED or described with a MUST or SHALL, it can be considered OPTIONAL....
    Read more >
    OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
    A URL to the license used for the API. This MUST be in the form of a URL. The url field is mutually...
    Read more >
    W3C XML Schema Definition Language (XSD) 1.1 Part 1
    This specification depends on XML Schema Definition Language 1.1 Part ... a required attribute information item, and the rest are optional.
    Read more >

    github_iconTop Related Medium Post

    No results found

    github_iconTop Related StackOverflow Question

    No results found

    github_iconTroubleshoot Live Code

    Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
    Start Free

    github_iconTop Related Reddit Thread

    No results found

    github_iconTop Related Hackernoon Post

    No results found

    github_iconTop Related Tweet

    No results found

    github_iconTop Related Dev.to Post

    No results found

    github_iconTop Related Hashnode Post

    No results found