swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

SwaggerEditor@next: syntax highlight for $ref key not working

Open tim-lai opened this issue 1 year ago • 3 comments

Q&A (please complete the following information)

  • Swagger-Editor version: v5.0.0-alpha.xx. Not sure if/when any of the alpha versions had a working semantic highlight for $ref
  • Swagger/OpenAPI version: any OpenAPI 3.x.x or AsyncAPI 2.x.x

Content & configuration

use fixtures on editor-next.swagger.io. e.g. any of OpenAPI 3.0 Petstore Fixture, AsyncAPI 2.5 Streetlights Fixture, OpenAPI 3.1 Fixture

Describe the bug you're encountering

Display of semantic highlighting for $ref is not working. Applies to various possible Reference Object locations. In the dark theme, $ref currently appears as grey.

To reproduce...

Steps to reproduce the behavior:

  1. Use fixtures on editor-next.swagger.io. e.g. any of OpenAPI 3.0 Petstore Fixture, AsyncAPI 2.5 Streetlights Fixture, OpenAPI 3.1 Fixture
  2. Look for any $ref
  3. See grey color appearance

Expected behavior

The $ref key should be non-grey color. Currently expecting "orange-ish", but could also have fontStyle: "bold" and/or be a different color.

Screenshots

Additional context or thoughts

tim-lai avatar Nov 07 '22 17:11 tim-lai

@char0n @tim-lai

This is because we don't have metadata for ref key (it's just a string), and mechanism is based on metadata.

we can solve this either :

  1. by adding metadata to $ref keys elements

or

  1. tweaking logic for this specific case, harcoding some name to map these keys with, like reference-value-key or something, this would not work for languages/format where such keys are named differently than $ref; this is not something we have at the moment though.

In terms of "right way" I'd say Option 1 maybe better (you'd probably be quicker to add these changes to reference elements in namespaes), but no strong objection at this stage to go for the non-metadata Option 2

Please let me know what you think

frantuma avatar Nov 08 '22 14:11 frantuma

@frantuma, right 1.) is systematic solution so let's go for it.

Here is how the metadata will look like after this issue is processed:

Symbolic Expression representation:

ReferenceElement // classes: [reference-element]
  MemberElement
    key=$ref // classes: [reference-key]
    value=<abtirary> // classes: [reference-value]

Classes reference-element and reference-value are already present. The scope of this issue is to add the reference-key class metadata.

char0n avatar Nov 08 '22 16:11 char0n

@char0n excellent, just a note: the reference-key added to classes should be added to tokens

frantuma avatar Nov 09 '22 09:11 frantuma