Comments (13)
it would be wonderful if you could open source the validation code in https://app.slack.com/block-kit-builder
from slack-api-specs.
Curious to see that there hasn't been any notice on this for almost four years. As far as I can see, Block Kit is still the way to go for displaying UI in Slack, right? Having no way to validate it makes for fairly poor developer experience 😕
from slack-api-specs.
I'm not someone at slack but took a look!
TLDR: With some manual effort and the typescript type information I semi-auto generated the schema. Here it is for others to use. Note: It validates an array of blocks for input.
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "some message",
"emoji": true
}
}
]
How?:
Talking with @itoys he suggested this approach using the typescript definitions for blocks to create a schema.
Doing that over this file gave me the definitions for the block types available 🥳
I then needed a top level definition for the to match the possible different block types, I did this with if-then
syntax for json schema.
"type": "object",
"properties": {
"type": {
"enum": [
"image",
"context",
"actions",
"divider",
"section",
"input",
"file",
"header",
"video",
"rich_text"
]
}
},
"required": [
"type"
],
"additionalProperties": true,
"allOf": [
{
"if": {
"properties": {
"type": {
"const": "image"
}
}
},
"then": {
"$ref": "#/definitions/ImageBlock"
}
},
{
"if": {
"properties": {
"type": {
"const": "context"
}
}
},
"then": {
"$ref": "#/definitions/ContextBlock"
}
},
from slack-api-specs.
it's quite hard to plan an integration and be sure it will work with real data without a schema, it would be great if you could publish it.
from slack-api-specs.
Btw, it looks like this JSON schema exists:
https://gist.github.com/renatorib/1fb1a9bd71435b41bee602d15bc56899
Would it be possible to share this JSON schema officially?
from slack-api-specs.
The schema that's mentioned in the gist, and here by @fab-mindflow is incomplete, it cuts out after ~18k characters, so it's an invalid schema right now.
from slack-api-specs.
Thanks to @okeeffed for the typescript to json schema code and awesome blog 🙇♂️
from slack-api-specs.
We want to offer full JSON schema (and a subset within our OpenAPI specs) for Block Kit but aren't yet ready to do so. In the meantime, the newest version of the spec on master includes a bare bones schema for blocks
and includes the blocks
parameter on methods that support them. Look for deeper support (including the difference between input and output blocks) in the future.
from slack-api-specs.
+1
It makes a lot of sense to add BlockKit JSON schema to OpenAPI specifications. Any news on this?
from slack-api-specs.
This was first open in 2019. Can someone at Slack take a look please?
from slack-api-specs.
Nudging this as it's super painful having to manually copy paste to the block builder website or only find out in a live system. I'd like to wrap my block generation client side in a unit test which validates the output against the JSON schema.
Given the tooling on the block kit builder has this to validate against I was hoping it's easy to publish 🙏
from slack-api-specs.
Stoked that it managed to help out @lawrencegripper ❤️
from slack-api-specs.
That schema is unfortunately also incomplete; many of Slack's blocks have limits on how many elements can appear in a list (e.g. an upper limit of 100 options in a dropdown select's options
field) or how long various strings can be (e.g. a 150 character limit for the text element in a header block) or even how many blocks a single definition is limited to.
from slack-api-specs.
Related Issues (20)
- Get all the messages with replies HOT 4
- Enhancement request: OpenAPI 3.0 support
- "token" header parameter not actually required
- Incomplete "consumes" definition for chat.postMessage
- Q: Bot vs. User token for reminders methods HOT 2
- Specify token type(s) for API methods in the spec
- Event payload of the `message` event does not have a consistent schema (missing `team` property when message subtype is `file_share`)
- 85 validation errors reported in Swagger Editor HOT 2
- Mark Repo as Unmaintained HOT 1
- `team.billableInfo` is wrong
- Request-URI Too Large for views.publish
- "Objs_user" has it's properties in a list called "items" but this isn't the case for the API - lookupByEmail
- Incorrect schema for calls.add and calls.info
- Required parameters are not marked as required
- Missing email_password_policy_enabled in admin.users.invite parameters
- objs_messages schema is wrong
- objs_file's user_team is wrong
- objs_message's attachment says id should be required but it is not always present
- Spec version is out of date with what the api allows
- Add the ability to slack API to query saved messages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack-api-specs.