Repository navigation
chore: extend Schema Object to allow defining custom formats - #797
magicmatatjahu wants to merge 8 commits into
Conversation
|
Kudos, SonarCloud Quality Gate passed! |
|
This pull request has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
8805c88 to
624ad52
Compare
There was a problem hiding this comment.
Just left a small comment.
This looks like it's ready to be reviewed, right @magicmatatjahu?
| "payload": { | ||
| "$ref": "path/to/user-create.avsc#/UserCreate" | ||
| "customSchema": { | ||
| "format": "application/vnd.apache.avro+json;version=1.9.0", |
There was a problem hiding this comment.
Would it not make sense to keep schemaFormat 🤔 ?
I'd not allow this. This requires changing JSON Schema. IMHO we should go in a direction where we get rid of the differences with JSON Schema instead of adding more "extra" keys. This also adds an incredible complexity for flexibility I doubt anyone would need. This is Avro inside a JSON Schema object but what about the opposite? Should we also alter Avro to accept JSON Schema inside? Aren't we mixing different things in the same place? I mean, JSON Schema is a constraint system and Avro is a data-serialization system. I know the same applies without this feature but at least we don't mix and match 🤔 |
|
More info why I'm closing -> #622 (comment) We can always reopen it, when we will have conclusion. |








title: "extend Schema Object to allow defining custom formats"
Related issue(s):
#622
This PR suggests how we could use custom schemas (in custom formats):
customSchemahas been added, which belongs to the AsyncAPI Schema Object vocabulary (described byCustom Schema Object)schemaFormatin theMessage Objectis deprecatedtitle,description,externalDocsalongsidecustomSchemakeywordExamples
Model defined by Custom Schema
{ "customSchema": { "format": "application/vnd.apache.avro+json;version=1.9.0", "definition": { "type": "record", "namespace": "com.example.common", "name": "Student", "fields": [ { "name": "Name", "type": "string" }, { "name": "Age", "type": "int" } ] } } }Model defined by Custom Schema with documentation fields
{ "title": "Student Model", "description": "A model describing a Student object, defined using the AVRO format.", "customSchema": { "format": "application/vnd.apache.avro+json;version=1.9.0", "definition": { "type": "record", "namespace": "com.example.common", "name": "Student", "fields": [ { "name": "Name", "type": "string" }, { "name": "Age", "type": "int" } ] } }, "externalDocs": { "description": "Find more info here", "url": "https://example.com" } }Model using nested Custom Schema Format
{ "type": "object", "properties": { "grades": { "type": "array", "items": { "type": "integer" } }, "student": { "customSchema": { "format": "application/vnd.apache.avro+json;version=1.9.0", "definition": { "type": "record", "namespace": "com.example", "name": "Student", "fields": [ { "name": "Name", "type": "string" }, { "name": "Age", "type": "int" } ] } } } } }Message with custom format (show usage of
$ref){ "name": "UserSignup", "title": "User signup", "summary": "Action to sign a user up.", "description": "A longer description", "tags": [ { "name": "user" }, { "name": "signup" }, { "name": "register" } ], "payload": { "customSchema": { "format": "application/vnd.apache.avro+json;version=1.9.0", "definition": { "$ref": "path/to/user-create.avsc" } } } }