Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use components for common params in OpenAPI spec #386

Open
david-crespo opened this issue Jun 25, 2022 · 1 comment
Open

Use components for common params in OpenAPI spec #386

david-crespo opened this issue Jun 25, 2022 · 1 comment

Comments

@david-crespo
Copy link
Contributor

I noticed in the Omicron OpenAPI spec that this block of pagination params appears about 25 times (with slight variations around sort mode). Obviously improving the human-readability and length of a machine-oriented spec is not particularly urgent, but it looks like this could be shortened quite a bit with global components.

"parameters": [
  {
    "in": "query",
    "name": "limit",
    "description": "Maximum number of items returned by a single call",
    "schema": {
      "nullable": true,
      "type": "integer",
      "format": "uint32",
      "minimum": 1
    },
    "style": "form"
  },
  {
    "in": "query",
    "name": "page_token",
    "description": "Token returned by previous call to retrieve the subsequent page",
    "schema": {
      "nullable": true,
      "type": "string"
    },
    "style": "form"
  },
  {
    "in": "query",
    "name": "sort_by",
    "schema": {
      "$ref": "#/components/schemas/IdSortMode"
    },
    "style": "form"
  }
],
@ahl
Copy link
Collaborator

ahl commented Aug 1, 2022

While reducing the size of the document may be beneficial, deduping is going to be more expensive than not. Likewise, this change might impose a greater burden on consumers of the document. I would opine that JSON is best suited for machine interpretation rather than human interpretation and therefore the "better" of two isomorphic constructions is the one that's simplest to represent. That said, I recognize that many--including the authors of the OpenAPI spec!--may disagree with this position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants