Skip to content

Commit 2b786e7

Browse files
Himenonclaude
andcommitted
test: add snapshot tests for PathItem-level path parameters with same-named query parameter
Add a Kubernetes-style scenario to the path-parameter fixture where: - Path parameters are defined at the PathItem level (not per-operation) - A query parameter shares the same name as one of the path parameters (`path`) - Multiple HTTP methods (GET, HEAD) inherit parameters from the PathItem This reproduces the pattern found in `connectCoreV1HeadNodeProxyWithPath` (/api/v1/nodes/{name}/proxy/{path}) from the Kubernetes OpenAPI spec, and captures the current code generation behavior as snapshot baselines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f980cc7 commit 2b786e7

5 files changed

Lines changed: 463 additions & 2 deletions

File tree

test/__tests__/class/__snapshots__/parameter-test.ts.snap

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,169 @@ exports[`Parameter > required フィールドを省略したパスパラメー
746746
}
747747
}
748748
},
749+
{
750+
"operationId": "getNodeProxyWithPath",
751+
"convertedParams": {
752+
"escapedOperationId": "getNodeProxyWithPath",
753+
"argumentParamsTypeDeclaration": "Params$getNodeProxyWithPath",
754+
"functionName": "getNodeProxyWithPath",
755+
"requestContentTypeName": "RequestContentType$getNodeProxyWithPath",
756+
"responseContentTypeName": "ResponseContentType$getNodeProxyWithPath",
757+
"parameterName": "Parameter$getNodeProxyWithPath",
758+
"requestBodyName": "RequestBody$getNodeProxyWithPath",
759+
"hasRequestBody": false,
760+
"hasParameter": true,
761+
"pickedParameters": [
762+
{
763+
"name": "name",
764+
"in": "path",
765+
"required": true
766+
},
767+
{
768+
"name": "path",
769+
"in": "path",
770+
"required": true
771+
},
772+
{
773+
"name": "path",
774+
"in": "query"
775+
}
776+
],
777+
"requestContentTypes": [],
778+
"responseSuccessNames": [
779+
"Response$getNodeProxyWithPath$Status$200"
780+
],
781+
"responseFirstSuccessName": "Response$getNodeProxyWithPath$Status$200",
782+
"has2OrMoreSuccessNames": false,
783+
"responseErrorNames": [],
784+
"has2OrMoreRequestContentTypes": false,
785+
"successResponseContentTypes": [
786+
"application/json"
787+
],
788+
"successResponseFirstContentType": "application/json",
789+
"has2OrMoreSuccessResponseContentTypes": false,
790+
"hasAdditionalHeaders": false,
791+
"hasQueryParameters": true
792+
},
793+
"operationParams": {
794+
"httpMethod": "get",
795+
"requestUri": "/nodes/{name}/proxy/{path}",
796+
"comment": "PathItem レベルのパスパラメータ継承 (GET)",
797+
"deprecated": false,
798+
"parameters": [
799+
{
800+
"in": "path",
801+
"name": "name",
802+
"schema": {
803+
"type": "string"
804+
},
805+
"required": true
806+
},
807+
{
808+
"in": "path",
809+
"name": "path",
810+
"schema": {
811+
"type": "string"
812+
},
813+
"required": true
814+
},
815+
{
816+
"in": "query",
817+
"name": "path",
818+
"schema": {
819+
"type": "string"
820+
}
821+
}
822+
],
823+
"responses": {
824+
"200": {
825+
"description": "OK",
826+
"content": {
827+
"application/json": {
828+
"schema": {
829+
"type": "string"
830+
}
831+
}
832+
}
833+
}
834+
}
835+
}
836+
},
837+
{
838+
"operationId": "headNodeProxyWithPath",
839+
"convertedParams": {
840+
"escapedOperationId": "headNodeProxyWithPath",
841+
"argumentParamsTypeDeclaration": "Params$headNodeProxyWithPath",
842+
"functionName": "headNodeProxyWithPath",
843+
"requestContentTypeName": "RequestContentType$headNodeProxyWithPath",
844+
"responseContentTypeName": "ResponseContentType$headNodeProxyWithPath",
845+
"parameterName": "Parameter$headNodeProxyWithPath",
846+
"requestBodyName": "RequestBody$headNodeProxyWithPath",
847+
"hasRequestBody": false,
848+
"hasParameter": true,
849+
"pickedParameters": [
850+
{
851+
"name": "name",
852+
"in": "path",
853+
"required": true
854+
},
855+
{
856+
"name": "path",
857+
"in": "path",
858+
"required": true
859+
},
860+
{
861+
"name": "path",
862+
"in": "query"
863+
}
864+
],
865+
"requestContentTypes": [],
866+
"responseSuccessNames": [],
867+
"has2OrMoreSuccessNames": false,
868+
"responseErrorNames": [],
869+
"has2OrMoreRequestContentTypes": false,
870+
"successResponseContentTypes": [],
871+
"has2OrMoreSuccessResponseContentTypes": false,
872+
"hasAdditionalHeaders": false,
873+
"hasQueryParameters": true
874+
},
875+
"operationParams": {
876+
"httpMethod": "head",
877+
"requestUri": "/nodes/{name}/proxy/{path}",
878+
"comment": "PathItem レベルのパスパラメータ継承 (HEAD)",
879+
"deprecated": false,
880+
"parameters": [
881+
{
882+
"in": "path",
883+
"name": "name",
884+
"schema": {
885+
"type": "string"
886+
},
887+
"required": true
888+
},
889+
{
890+
"in": "path",
891+
"name": "path",
892+
"schema": {
893+
"type": "string"
894+
},
895+
"required": true
896+
},
897+
{
898+
"in": "query",
899+
"name": "path",
900+
"schema": {
901+
"type": "string"
902+
}
903+
}
904+
],
905+
"responses": {
906+
"200": {
907+
"description": "OK"
908+
}
909+
}
910+
}
911+
},
749912
{
750913
"operationId": "getUserPost",
751914
"convertedParams": {

test/__tests__/class/__snapshots__/typedef-with-template-test.ts.snap

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,17 @@ export interface Response$getItemById$Status$200 {
17561756
name?: string;
17571757
};
17581758
}
1759+
export interface Parameter$getNodeProxyWithPath {
1760+
name: string;
1761+
path?: string;
1762+
}
1763+
export interface Response$getNodeProxyWithPath$Status$200 {
1764+
"application/json": string;
1765+
}
1766+
export interface Parameter$headNodeProxyWithPath {
1767+
name: string;
1768+
path?: string;
1769+
}
17591770
export interface Parameter$getUserPost {
17601771
userId: string;
17611772
postId: number;
@@ -1771,6 +1782,13 @@ export type ResponseContentType$getItemById = keyof Response$getItemById$Status$
17711782
export interface Params$getItemById {
17721783
parameter: Parameter$getItemById;
17731784
}
1785+
export type ResponseContentType$getNodeProxyWithPath = keyof Response$getNodeProxyWithPath$Status$200;
1786+
export interface Params$getNodeProxyWithPath {
1787+
parameter: Parameter$getNodeProxyWithPath;
1788+
}
1789+
export interface Params$headNodeProxyWithPath {
1790+
parameter: Parameter$headNodeProxyWithPath;
1791+
}
17741792
export type ResponseContentType$getUserPost = keyof Response$getUserPost$Status$200;
17751793
export interface Params$getUserPost {
17761794
parameter: Parameter$getUserPost;
@@ -1787,9 +1805,11 @@ export interface QueryParameter {
17871805
export interface QueryParameters {
17881806
[key: string]: QueryParameter;
17891807
}
1790-
export type SuccessResponses = Response$getItemById$Status$200 | Response$getUserPost$Status$200;
1808+
export type SuccessResponses = Response$getItemById$Status$200 | Response$getNodeProxyWithPath$Status$200 | Response$getUserPost$Status$200;
17911809
export namespace ErrorResponse {
17921810
export type getItemById = void;
1811+
export type getNodeProxyWithPath = void;
1812+
export type headNodeProxyWithPath = void;
17931813
export type getUserPost = void;
17941814
}
17951815
export interface Encoding {
@@ -1825,6 +1845,36 @@ export class Client<RequestOption> {
18251845
headers
18261846
}, option);
18271847
}
1848+
/** PathItem レベルのパスパラメータ継承 (GET) */
1849+
public async getNodeProxyWithPath(params: Params$getNodeProxyWithPath, option?: RequestOption): Promise<Response$getNodeProxyWithPath$Status$200["application/json"]> {
1850+
const url = this.baseUrl + \`/nodes/\${encodeURIComponent(params.parameter.name)}/proxy/\${encodeURIComponent(params.parameter.path)}\`;
1851+
const headers = {
1852+
Accept: "application/json"
1853+
};
1854+
const queryParameters: QueryParameters = {
1855+
path: { value: params.parameter.path, explode: false }
1856+
};
1857+
return this.apiClient.request({
1858+
httpMethod: "GET",
1859+
url,
1860+
headers,
1861+
queryParameters: queryParameters
1862+
}, option);
1863+
}
1864+
/** PathItem レベルのパスパラメータ継承 (HEAD) */
1865+
public async headNodeProxyWithPath(params: Params$headNodeProxyWithPath, option?: RequestOption): Promise<void> {
1866+
const url = this.baseUrl + \`/nodes/\${encodeURIComponent(params.parameter.name)}/proxy/\${encodeURIComponent(params.parameter.path)}\`;
1867+
const headers = {};
1868+
const queryParameters: QueryParameters = {
1869+
path: { value: params.parameter.path, explode: false }
1870+
};
1871+
return this.apiClient.request({
1872+
httpMethod: "HEAD",
1873+
url,
1874+
headers,
1875+
queryParameters: queryParameters
1876+
}, option);
1877+
}
18281878
/** 複数のパスパラメータで required を省略したケース */
18291879
public async getUserPost(params: Params$getUserPost, option?: RequestOption): Promise<Response$getUserPost$Status$200["application/json"]> {
18301880
const url = this.baseUrl + \`/users/\${encodeURIComponent(params.parameter.userId)}/posts/\${encodeURIComponent(params.parameter.postId)}\`;

0 commit comments

Comments
 (0)