Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected reference depth #1348

Open
ghost opened this issue Nov 3, 2023 · 2 comments · May be fixed by #1392
Open

Unexpected reference depth #1348

ghost opened this issue Nov 3, 2023 · 2 comments · May be fixed by #1392
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Nov 3, 2023

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

@jamietanna
Copy link
Member

jamietanna commented Dec 13, 2023

Interesting! I think this isn't a use-case we expected, but I can see why it's useful.

I wonder if a fix for this is best gated behind a flag to allow folks to opt-in to the changes, but I'd be happy with there being support added for this, and would review a PR that's raised for it!

@jamietanna jamietanna added the enhancement New feature or request label Dec 13, 2023
jamietanna added a commit that referenced this issue Dec 18, 2023
In my opinion, this check doesn't seem to be providing much value, and
we've got a few folks requesting this be disabled.

Instead of gating this behind a feature flag, we'll just remove it.

Closes #1348.
jamietanna added a commit that referenced this issue Dec 18, 2023
@jamietanna jamietanna linked a pull request Dec 18, 2023 that will close this issue
@bjuan210302
Copy link

Any updates on this? Facing the same issue and don't really know what it's about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants