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

asyncapi import fails to import more complex schema #1868

Open
budziam opened this issue Apr 18, 2023 · 1 comment
Open

asyncapi import fails to import more complex schema #1868

budziam opened this issue Apr 18, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@budziam
Copy link

budziam commented Apr 18, 2023

Hi,
first of all I would like to thank you for implementing confluent asyncapi import command. It's extremely useful!

Unfortunately, it looks like it doesn't handle $ref too well. Check out the following example.

confluent asyncapi import --file asyncapi.yaml --overwrite --unsafe-trace
asyncapi: 2.6.0

info:
  title: Example
  version: 1.0.0

channels:
  entitlements-v1:
    x-messageCompatibility: NONE
    subscribe:
      operationId: EntitlementsV1Subscribe
      message:
        $ref: "#/components/messages/EntitlementsV1Message"

components:
  messages:
    EntitlementsV1Message:
      name: EntitlementsV1Message
      contentType: application/json
      payload:
        title: EntitlementsV1Message
        type: object
        required:
          - uuid
          - level
        properties:
          uuid:
            type: string
            format: uuid
          level:
            $ref: "#/components/schemas/EntityLevel"

  schemas:
    EntityLevel:
      type: string
      enum:
        - team
        - org

The result is as follows:

POST /subjects/entitlements-v1-value/versions HTTP/1.1
User-Agent: Confluent-CLI/v3.10.0 (https://confluent.io; [email protected])
Content-Length: 251
Accept: application/vnd.schemaregistry.v1+json,application/vnd.schemaregistry+json; qs=0.9,application/json; qs=0.5
Content-Type: application/json
Accept-Encoding: gzip

{"schemaType":"JSON","schema":"{\"properties\":{\"level\":{\"$ref\":\"#/components/schemas/EntityLevel\"},\"uuid\":{\"format\":\"uuid\",\"type\":\"string\"}},\"required\":[\"uuid\",\"level\"],\"title\":\"EntitlementsV1Message\",\"type\":\"object\"}"}

HTTP/2.0 422 Unprocessable Entity
Content-Length: 390
Content-Type: application/vnd.schemaregistry.v1+json
Date: Tue, 18 Apr 2023 11:34:24 GMT

{"error_code":42201,"message":"Invalid schema {subject=entitlements-v1-value,version=0,id=-1,schemaType=JSON,references=[],schema={\"properties\":{\"level\":{\"$ref\":\"#/components/schemas/EntityLevel\"},\"uuid\":{\"format\":\"uuid\",\"type\":\"string\"}},\"required\":[\"uuid\",\"level\"],\"title\":\"EntitlementsV1Message\",\"type\":\"object\"}}, details: #: key [components] not found"}

[WARN]  unable to register schema: 422 Unprocessable Entity

As far as I can see, the problem is caused by the fact that the body of POST /subjects/entitlements-v1-value/versions request contains message schema only - without components/schema part.

@budziam budziam changed the title asyncapi import fails with more complex schema asyncapi import fails to import more complex schema Apr 18, 2023
@brianstrauch brianstrauch assigned kcorman0 and unassigned pagrawal10 May 9, 2023
@brianstrauch brianstrauch added the bug Something isn't working label May 9, 2023
@brianstrauch
Copy link
Member

Thanks for opening this issue! We've added it to our roadmap and will provide updates here when we start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants