swagger-api / swagger-api/swagger-parser

'#/paths/~1path/get/requestBody/content/application~1json/schema' not resolved with ResolverFully

Open
#596 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.0 spec support Bug P2
Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Bug

The local refs to another schema inside a path definition is not resolved using ResolverFully. This types of refs are discouraged, but they can be done according to spec and docs https://swagger.io/docs/specification/using-ref/

Steps to reproduce

Try to load with setResolveFully true this spec:

openapi: 3.0.0
info:
  version: 1.0.0
  title: JSON Schemas test spec
  license:
    name: MIT
paths:
  /test1:
    get:
      operationId: test1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Person'
      responses:
        default:
          description: "OK"
  /test4:
    get:
      operationId: test4
      responses:
        default:
          description: "OK"
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/paths/~1test1/get/requestBody/content/application~1json/schema'
                - $ref: '#/components/schemas/Citizen'

components:
  schemas:
    Person:
      type: object
      additionalProperties: {}
      properties:
        name:
          type: string
        surname:
          type: string
      required:
        - name
        - surname
    Citizen:
      type: object
      additionalProperties: {}
      properties:
        id_card:
          type: string
      required:
        - id_card

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 by loading the supplied OpenAPI YAML with setResolveFully(true) and inspect ResolverFully's handling of the local path reference in /test4. Trace why '#/paths/1test1/get/requestBody/content/application1json/schema' is not resolved, then verify that the request-body schema resolves successfully without breaking the components-schema references.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.