Unexpected reference depth
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
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!
Any updates on this? Facing the same issue and don't really know what it's about
This may now be closed by https://github.com/oapi-codegen/oapi-codegen/pull/1689 and some follow up changes - would it be possible for someone affected to validate?