docs(api): mark collection responses nullable (#6430)

* docs(api): mark collection responses nullable

Describe allLinks and panel log response objects as nullable string arrays so generated clients accept the existing nil-slice wire format. Pin both schemas with buildSpec regression assertions and regenerate the OpenAPI copies.

* docs(api): include nullable Xray log responses

Allow generated response arrays to opt into nullability while retaining their schema references and Go-derived examples. Apply this to Xray logs, whose nil slices already serialize as null, and pin the schema and example through buildSpec.
This commit is contained in:
Gleb Gudkov
2026-09-08 18:12:09 +03:00
committed by GitHub
parent 3cd3836d77
commit b8597314f8
5 changed files with 46 additions and 5 deletions
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { buildSpec } from '../../scripts/build-openapi.mjs';
import { EXAMPLES } from '../generated/examples';
interface OpenApiSchema {
$ref?: string;
@@ -31,7 +32,7 @@ interface OpenApiOperation {
responses: Record<
string,
{
content?: Record<string, { schema: OpenApiSchema }>;
content?: Record<string, { schema: OpenApiSchema; example?: unknown }>;
}
>;
security?: Record<string, never[]>[];
@@ -127,15 +128,30 @@ describe('generated OpenAPI runtime contracts', () => {
});
});
it('documents all inbound links as a nullable string array', () => {
expect(responseObjectSchema('/panel/api/inbounds/allLinks')).toEqual({
type: 'array',
nullable: true,
items: { type: 'string' },
});
});
it('uses the runtime REST response schemas', () => {
expect(responseObjectSchema('/panel/api/server/logs/{count}', 'post')).toEqual({
type: 'array',
nullable: true,
items: { type: 'string' },
});
expect(responseObjectSchema('/panel/api/server/xraylogs/{count}', 'post')).toEqual({
type: 'array',
nullable: true,
items: { $ref: '#/components/schemas/LogEntry' },
});
expect(
operation('/panel/api/server/xraylogs/{count}', 'post').responses['200'].content?.[
'application/json'
].example,
).toEqual({ success: true, obj: [EXAMPLES.LogEntry] });
expect(responseObjectSchema('/panel/api/server/getNewUUID')).toEqual({
$ref: '#/components/schemas/NewUUIDResponse',
});