Skip to content

fix: fix no-$ref-siblings error - #1048

Merged
shenbenson merged 1 commit into
masterfrom
dx-1580-no-ref-siblings
Jul 29, 2025
Merged

fix: fix no-$ref-siblings error#1048
shenbenson merged 1 commit into
masterfrom
dx-1580-no-ref-siblings

Conversation

@shenbenson

@shenbenson shenbenson commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Fixes the no-$ref-siblings error seen in this PR

Ticket: DX-1580

This is done by wrapping innerSchema $ref's in an allOf in the case that a ref is present and has siblings.

Result:

The following code:

import * as t from 'io-ts';
import * as h from '@api-ts/io-ts-http';
/**
 * A simple route with type descriptions for references
 *
 * @operationId api.v1.test
 * @tag Test Routes
 */
export const route = h.httpRoute({
  path: '/foo',
  method: 'GET',
  request: h.httpRequest({}),
  response: {
    200: SimpleRouteResponse
  },
 });


 /**
  * Human readable description of the Simple Route Response
  * @title Human Readable Simple Route Response
 */
const SimpleRouteResponse = t.type({
  /** List of test refs */
  test: t.array(TestRef)
});

const TestRefBase = t.string;

const TestRef = TestRefBase;

Now results in:

  {
    openapi: '3.0.3',
    info: {
      title: 'Test',
      version: '1.0.0',
    },
    paths: {
      '/foo': {
        get: {
          summary: 'A simple route with type descriptions for references',
          operationId: 'api.v1.test',
          tags: ['Test Routes'],
          parameters: [],
          responses: {
            '200': {
              description: 'OK',
              content: {
                'application/json': {
                  schema: {
                    $ref: '#/components/schemas/SimpleRouteResponse',
                  },
                },
              },
            },
          },
        },
      },
    },
    components: {
      schemas: {
        SimpleRouteResponse: {
          description: 'Human readable description of the Simple Route Response',
          properties: {
            test: {
              type: 'array',
              items: {
+              allOf: [{ $ref: '#/components/schemas/TestRefBase' }],
-              $ref: '#/components/schemas/TestRefBase',
                description: 'List of test refs',
              },
            },
          },
          required: ['test'],
          title: 'Human Readable Simple Route Response',
          type: 'object',
        },
        TestRefBase: {
          title: 'TestRefBase',
          type: 'string',
        },
        TestRef: {
          allOf: [
            {
              title: 'TestRef',
            },
            {
              $ref: '#/components/schemas/TestRefBase',
            },
          ],
        },
      },
    },
  }

@starfy84
starfy84 force-pushed the dx-1580-no-ref-siblings branch from f11c59d to e5a1b81 Compare July 29, 2025 15:04
@starfy84 starfy84 self-assigned this Jul 29, 2025
@starfy84
starfy84 force-pushed the dx-1580-no-ref-siblings branch from e5a1b81 to 23a0df8 Compare July 29, 2025 15:12
@starfy84
starfy84 marked this pull request as ready for review July 29, 2025 15:15
@starfy84
starfy84 requested a review from a team as a code owner July 29, 2025 15:15
Fixes the no-$ref-siblings error seen in this [PR](BitGo/dev-portal#2508)

Ticket: DX-1580
@starfy84
starfy84 force-pushed the dx-1580-no-ref-siblings branch from 23a0df8 to cbe1c86 Compare July 29, 2025 15:47

@ericcrosson-bitgo ericcrosson-bitgo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alley-oop'ing

Thanks @shenbenson and @starfy84!

@shenbenson
shenbenson merged commit 8b3e259 into master Jul 29, 2025
6 checks passed
@shenbenson
shenbenson deleted the dx-1580-no-ref-siblings branch July 29, 2025 20:15
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version @api-ts/openapi-generator@5.10.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown

🎉 This PR is included in version @api-ts/typed-express-router@2.0.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown

🎉 This PR is included in version @api-ts/express-wrapper@2.0.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants