elements icon indicating copy to clipboard operation
elements copied to clipboard

Specify schema nodes in the body listing with a ref to the schema node

Open hellt opened this issue 11 months ago • 6 comments

User Story Description

As a User,

I want to see the link to the schema node listed in the body map,

Image

so I can see the schema node reference for a body field I am browsing. As in the screenshot above, the crs field is not just an array[object] but is an array[TransactionCr] where TransactionCr is a schema node.

Consider the swagger ui and the way this information is presented

Image

Acceptance Criteria

  • [ ]

Sprint Ready Checklist

  • [ ] Acceptance criteria defined
  • [ ] Team understands acceptance criteria
  • [ ] Team has defined solution / steps to satisfy acceptance criteria
  • [ ] Acceptance criteria is verifiable / testable
  • [ ] External / 3rd Party dependencies identified

hellt avatar Jan 22 '25 09:01 hellt

Hi @ben-smartbear This sounds like an important feature Stoplight Elements should already have. Is there an official channel where this feature can be requested and worked on so that it does not go overlooked? Cheers!

CristianDuta avatar Jun 24 '25 06:06 CristianDuta

It appears that by the time the data is passed to the JsonSchemaViewer (@stoplight/json-schema-viewer) the required information is no longer present.

  • it would need to be added to the resolved model before it's passed to the schema viewer
  • the schema viewer would need to be extended to access the new property

The first could be achieved by patching the ReferenceResolver.

From

https://github.com/stoplightio/elements/blob/88a02fdc8620613f89d0f9eb9ec8fc86405fae56/packages/elements-core/src/utils/ref-resolving/ReferenceResolver.ts#L26

to

if (resolved) {
  resolved.objectRefType = pointer.replace('#/components/schemas/', '');
  return resolved;
}

marcelstoer avatar Jul 03 '25 12:07 marcelstoer

@darekplawecki could you or anyone else in your team please confirm whether the implementation plan I laid out above is feasible?

I built a prototype adding a objectRefType property (see above).

I then modified https://github.com/stoplightio/json-schema-viewer/blob/master/src/components/shared/Types.tsx#L72 and included schemaNode.fragment.objectRefType.

Instead of 'object' (i.e. the type) we would print the $ref type.

Image

marcelstoer avatar Jul 15 '25 09:07 marcelstoer

@hellt I'd be interested in hearing from you if what I prototyped is close to what you were asking for.

marcelstoer avatar Jul 15 '25 14:07 marcelstoer

@marcelstoer judging by the screenshot I can't say if you can click on the $ref and jump to the schema object definition?

hellt avatar Jul 15 '25 14:07 hellt

My prototype doesn't support that yet. The first goal was to be on-par with what Swagger UI offers.

marcelstoer avatar Jul 15 '25 14:07 marcelstoer