Skip to content

feat(multi format schema): support new media types #569

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion definitions/3.0.0/multiFormatSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
"application/vnd.apache.avro+json;version=1.9.0",
"application/vnd.apache.avro+yaml;version=1.9.0",

"application/raml+yaml;version=1.0"
"application/raml+yaml;version=1.0",

"application/vnd.google.protobuf;version=2",
"application/vnd.google.protobuf;version=3",

"application/xml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need it here? in the end, it works without it listed here right? in the spec xml is not listed in the list of recommeneded schemas - and also, it is anyway just recommended

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, otherwise here will be error

image

asyncapi: 3.0.0
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  userSignedUp:
    address: user/signedup
    messages:
      UserSignedUp:
        $ref: '#/components/messages/userSignedUp'
operations:
  sendUserSignedUp:
    action: send
    channel:
      $ref: '#/channels/userSignedUp'
    messages:
      - $ref: '#/channels/userSignedUp/messages/UserSignedUp'
components:
  messages:
    userSignedUp:
      payload:
        schemaFormat: application/xml
        schema: |
          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="User">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="displayName" type="xs:string">
                      <xs:annotation>
                        <xs:documentation>Name of the user</xs:documentation>
                      </xs:annotation>
                  </xs:element>
                  <xs:element name="email" type="xs:string">
                      <xs:annotation>
                        <xs:documentation>Email of the user</xs:documentation>
                      </xs:annotation>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:schema>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is anyway just recommended

Yep, it's recommendation. But folks from Specmatic already have scenarios where they are using .xsd as payload schema

Without proper registration UI component will not work because of error in our parser

Error thrown during AsyncAPI document parsing. Name: Error, message: Unknown schema format

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

]
}
]
Expand Down Expand Up @@ -194,6 +199,37 @@
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/raml+yaml;version=1.0",
"application/vnd.google.protobuf;version=2",
"application/vnd.google.protobuf;version=3",
"application/xml"
]
}
}
},
"then": {
"properties": {
"schema": {
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"type": ["string", "object"]
}
]
}
}
}
}
]
},
Expand Down