Skip to content

Unexpected reference depth #1348

@ghost

Description

Issue

Error occurs when $ref refers to a property of another object.

This feature can be useful because it allows you to edit the properties of an object in one place (especially when using different models for requests).

Example

openapi: 3.0.3
info:
  title: test-service
  version: 1.0.0

paths:
  /samples:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSample"
      responses:
        201:
          description: ".."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Sample"

components:
  schemas:
    Sample:
      type: object
      properties:
        id:
          type: string
          format: uuid
        field:
          type: string
          # more properties here

    CreateSample:
      type: object
      properties:
        field:
          $ref: "#/components/schemas/Sample/properties/field"

Output

Error generating code: error generating type definitions: error generating Go types for component schemas: error converting Schema CreateSample to Go type: error generating Go schema for property 'field': error turning reference (#/components/schemas/Sample/properties/field) into a Go type: unexpected reference depth: 6 for ref: #/components/schemas/Sample/properties/field local: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions