Skip to content

dereferencing an external schema doesn't need to change the object name #28

@steve-nay-sage

Description

@steve-nay-sage

Summary

The goal of this issue is to improve how external schema references look when dereferenced. Currently, an external reference like this:

components:
  schemas:
    account:
      $ref: ../models/account..s1.schema.yaml

when dereferenced looks something like this:

components:
  schemas:
    account:
      $ref: '#/components/schemas/Account_S1_Schema'
    Account_S1_Schema
      title: Account
      type: object
      description: General Ledger Account
      properties:
      .
      .
      .

The original external reference gets replaced with a new internal reference to a new object that has a name that is derived from the external file name. It doesn't seem like it's necessary to create a new object, and it looks kind of silly. (It's functional, though.)

Instead, the external reference should just be replaced with the contents of the file that it points to:

components:
  schemas:
    account:
      title: Account
      type: object
      description: General Ledger Account
      properties:
      .
      .
      .

I think this would be an improvement to external references that originate in the components/schemas section. External references from the paths section would need to be treated differently because a new internal schema would need to be created. In that case, I recommend using the title of the object as the object name if the schema contains a title, and only using the file name if there is no title.

Additional context

I haven't used the JSON schema ref parser in its standalone form; I've only used it by exporting from Stoplight, and Stoplight support folks told me that this is the actual source project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions