backstage: $ref : Error downloading

Hi

External ref to a schema doesn’t seem to work

Here’s my case: I’ve got a API described by this : api-info.yaml

apiVersion: backstage.io/v1alpha1
kind: API
metadata:
  name: bridge-machine-service-maintenance-kafka
  description: bridge machine service maintenance kafka
spec:
  type: asyncapi
  lifecycle: production
  definition: 
    $text: ./contract.yml

And the asyncapi contract looks like : contract.yml

asyncapi: "2.1.0"
info:
  title: bridge-machine-service-maintenance
  version: "1.0.0"
  description: |
    This service 

channels:
  public.data.service.tracking.consolidated:
    description: Maintenance intervention messages from kafka
    bindings:
      kafka:
        topic:
          partitions: 5
          cleanup.policy: delete
    publish:
      operationId: consumeMaintenanceIntervention
      traits:
        - $ref: "#/components/operationTraits/kafkaConsume"
      message:
        $ref: "#/components/messages/maintenanceInterventionPayload"
        
components:
  messages:
    maintenanceInterventionPayload:
      name: Maintenance intervention
      title: Maintenance intervention message
      summary: This is the definition of a maintenance intervention message
      traits:
        - $ref: "#/components/operationTraits/kafkaKey"
      schemaFormat: "application/vnd.apache.avro;version=1.9.0"
      contentType: avro
      payload:
        - $ref: "https://raw.githubusercontent.com/ept/avrodoc/master/schemata/example.avsc"
    
  operationTraits:
    kafkaConsume:
      bindings:
        kafka:
          groupId:
            type: string
            enum: ["bridge-machine-service-maintenance"]
    kafkaKey:
      bindings:
        kafka:
          key:
            type: string
            description: Equipment serial number

Expected Behavior

The external ref should be well parsed

      payload:
        - $ref: "https://raw.githubusercontent.com/ept/avrodoc/master/schemata/example.avsc"

The result shoud be like when I use the editor https://asyncapi.github.io/asyncapi-react/ with the content of contract.yml

Current Behavior

I’ve got an error in the asynapi tab : Error: Error downloading https://raw.githubusercontent.com/ept/avrodoc/master/schemata/example.avsc (intermediate value)(intermediate value)(intermediate value).get is not a function

Steps to Reproduce

  1. create an API with api-info.yaml (see above)
  2. go to <Backstage_base_url>/catalog/default/api/bridge-machine-service-maintenance-kafka/definition

Regards

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32 (22 by maintainers)

Most upvoted comments

@Rugvip can be closed as it’s solved.

Great ! With the visibility inside additionalProperties, it works.

Thanks a lot @benjdlambert

Thank you! Sounds like enough cause to reopen 😁

I have been meaning to open an issue about this for a couple months now.

The issue is that the @apidevtools/json-schema-ref-parser dependency that is used by @asyncapi/parser that is used by @asyncapi/react-component uses the node http and https to resolve these urls. You can see where it is failing here.

@asyncapi/parser has a section in their README about using it in the browser but I haven’t gotten around to coming up with a solution for it.

Having said all that, @Rugvip and @Fox32 I believe this is not a duplicate of #6832 and should be reopened.