Skip to content

Make Paths Object Optional #1045

Closed
Closed
@tedepstein

Description

@tedepstein

The Paths Object is required to be present in the OpenAPI Object.

This makes it awkward to create an OpenAPI spec that serves as a "catalog" of reusable components. This is already a common usage pattern in OpenAPI 2.0, and we expect it will be even more common with OpenAPI 3.0, with the introduction of the Components Object, and new types of reusable definitions contained within it.

It's possible to create a catalog file, but you have to do one of two things:

  1. Use JSON's empty object syntax, because there is no explicit empty object syntax in YAML. This works, but it's awkward, and is just a way of getting around the requirement. to have a Paths Object. Here's a 2.0 example:
---
swagger: "2.0"
info:
  version: 1.0.0
  title: Uber Schema Definitions

# This is a component file, used by the Uber API specification. 
# The paths property is required, so we use curly braces to denote an empty object,
# meaning there are no path items defined in this file. 
paths: {}

# The definitions section contains a set of named Schema Objects. Each object
# describes a reusable data type. We refer to these using a $ref property, with a 
# JSON Reference value that resolves to the definition.
definitions:
  
  PriceEstimate:
    type: object
    properties:
      product_id:
        type: string
        description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles
  ...

OR...

  1. Use a YAML or JSON file format that is not valid OpenAPI, specifically for catalog files. This means the file can't be processed by standard OpenAPI documentation tools, code generators and other processors, if those tools include schema validation (or the equivalent). And it means we don't have an implementation-independent standard format for catalog files.

So I would argue for making paths optional.

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