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

Global parameters (traits) #7

Open
chriskapp opened this issue Apr 28, 2024 · 0 comments
Open

Global parameters (traits) #7

chriskapp opened this issue Apr 28, 2024 · 0 comments

Comments

@chriskapp
Copy link
Member

On some APIs there are global parameters which are applied on every API request i.e. the Notion API has a Notion-Version header which is required for every request s.

image

Currently we can only add an argument for each operation where we provide this header value. It would be better if we could globally configure this header value and automatically add this to every operation. We could add some sort of traits where we define arguments and then use those traits at every operation s.

{
  "traits": {
    "version": {
      "Notion-Version": {
        "in": "header",
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "operations": {
    "getMessage": {
      "description": "Returns a hello world message",
      "method": "GET",
      "path": "/hello/world",
      "traits": ["version"],
      "return": {
        "schema": {
          "$ref": "Hello_World"
        }
      }
    }
  },
  "definitions": {
    "Hello_World": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        }
      }
    }
  }
}
const client = new Client()
client.setVersion("2022-06-28");
client.getMessage(): HelloWorld

This should then include the version header for the getMessage call.

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

1 participant