Pylons / Pylons/pyramid_openapi3

Need help with using $refs

Open
#192 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
84
Forks
46
Avg merge
5d 20h
Merged PRs (30d)
3

Description

My current directory structure:

| spec
      | main.yaml
      | template.yaml
      | organisation
          | organisation.yaml

I am trying to import a schema written in template.yaml to organisation.yaml. organisation.yaml contains operations for a path and it will again be added via refs to main.yaml to a path.

I am facing an issue when trying to reference a schema template.yaml in organisation.yaml.

organisation.yaml

get:
    summary: Fetch an organisation's data
    responses:
      "200":
        description: ok
        content:
          application/json:
            schema:
              type: object
              properties:
                gkstatus:
                  $ref: "../template.yaml#/components/schemas/gkstatus"
  1. When I try ../template.yaml, it searches in the parent directory of spec
  2. When I try ../spec/template.yaml, it searches in /spec/spec/template.yaml
  3. I got it working by having a copy of template.yaml inside the organisation folder and one inside the spec folder near the main.yaml file

I am confused, can some one help me out?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with spec/main.yaml, spec/template.yaml, and spec/organisation/organisation.yaml, then trace how the project resolves the relative $ref from the nested file. Confirm the supported reference base and verify that the schema can be reused without duplicate copies of template.yaml.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.