Skip to content

fix(array-pointer): support array pointer for ref#2073

Open
zdunecki wants to merge 1 commit into
oapi-codegen:mainfrom
zdunecki:fix/array-pointer
Open

fix(array-pointer): support array pointer for ref#2073
zdunecki wants to merge 1 commit into
oapi-codegen:mainfrom
zdunecki:fix/array-pointer

Conversation

@zdunecki

@zdunecki zdunecki commented Sep 2, 2025

Copy link
Copy Markdown

Hi,

There's a fix for this case:

components:
  schemas:
    response.Placeholder:
      x-go-embedding: true
      type: object
      allOf:
        - $ref: "#/components/schemas/Response"
        - type: object
          properties:
            hello:
              type: string
            past_7_days_histogram:
              type: array
              x-go-type-skip-optional-pointer: true
              nullable: true
              items:
                allOf:
                  - $ref: '#/components/schemas/DateHistogram'

    DateHistogram:
      type: object
      properties:
        key:
          type: string
        key_as_string:
          type: string
          nullable: true
        doc_count:
          type: integer

I would expect it will produce in Go code like that:

type ResponsePlaceholder struct {
	Hello              *string          `json:"hello,omitempty"`
	Past7DaysHistogram []*DateHistogram `json:"past_7_days_histogram"`
}

The key is - []*DateHistogram.

Currently, it's not possible to declare type: array with an external $ref and a pointer(*). I tried multiple ways and still get []DateHistogram.

This PR should fix that.

Best,

@zdunecki zdunecki requested a review from a team as a code owner September 2, 2025 17:00
@kusari-inspector

Copy link
Copy Markdown

Kusari Inspector

Kusari Analysis Results:

Proceed with these changes

✅ No Flagged Issues Detected
All values appear to be within acceptable risk parameters.

No pinned version dependency changes, code issues or exposed secrets detected!

@kusari-inspector rerun - Trigger a re-analysis of this PR
@kusari-inspector feedback [your message] - Send feedback to our AI and team
See Kusari's documentation for setup and configuration.
Commit: ada15fd, performed at: 2025-09-02T17:00:51Z

Found this helpful? Give it a 👍 or 👎 reaction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant