CLI-3564: asyncapi import fails to import more complex schema

Abierto
#1,868 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@kcorman0 ya está trabajando en esto.

Desde el 9/5/2023.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug

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.

Lenguaje dominante
Go
Estrellas
82
Forks
37
Merge medio
1 d 13 h
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de confluentinc/cli

Todos los issues de confluentinc/cli

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.