Skip to content

Commit

Permalink
Merge branch 'master' into make-v22
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Dec 20, 2024
2 parents e2492a1 + 9575db7 commit a8bed37
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 135 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

## Version 21

### v21.8.0

- Deprecating `jsonEndpoints` from the code generated by `Integration`:
- Use the `content-type` header of an actual response instead, [example](#v20212).

### v21.7.0

- Feature: introducing `EncodedResponse` public interface in the code generated by `Integration`:
Expand Down
1 change: 1 addition & 0 deletions example/example.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export interface Response {

export type MethodPath = keyof Input;

/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = {
"get /v1/user/retrieve": true,
"patch /v1/user/:id": true,
Expand Down
14 changes: 9 additions & 5 deletions src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { Routing } from "./routing";
import { OnEndpoint, walkRouting } from "./routing-walker";
import { HandlingRules } from "./schema-walker";
import { zodToTs } from "./zts";
import { ZTSContext, printNode } from "./zts-helpers";
import { ZTSContext, printNode, addJsDocComment } from "./zts-helpers";
import type Prettier from "prettier";

type IOKind = "input" | "response" | ResponseVariant | "encoded";
Expand Down Expand Up @@ -116,6 +116,7 @@ export class Integration {
negResponseInterface: f.createIdentifier("NegativeResponse"),
encResponseInterface: f.createIdentifier("EncodedResponse"),
responseInterface: f.createIdentifier("Response"),
/** @todo remove in v22 */
jsonEndpointsConst: f.createIdentifier("jsonEndpoints"),
endpointTagsConst: f.createIdentifier("endpointTags"),
implementationType: f.createIdentifier("Implementation"),
Expand Down Expand Up @@ -301,10 +302,13 @@ export class Integration {
if (variant === "types") return;

// export const jsonEndpoints = { "get /v1/user/retrieve": true }
const jsonEndpointsConst = makeConst(
this.ids.jsonEndpointsConst,
f.createObjectLiteralExpression(jsonEndpoints),
{ expose: true },
const jsonEndpointsConst = addJsDocComment(
makeConst(
this.ids.jsonEndpointsConst,
f.createObjectLiteralExpression(jsonEndpoints),
{ expose: true },
),
"@deprecated use content-type header of an actual response",
);

// export const endpointTags = { "get /v1/user/retrieve": ["users"] }
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/__snapshots__/integration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Response {
export type MethodPath = keyof Input;
/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = { "post /v1/test-with-dashes": true };
export const endpointTags = { "post /v1/test-with-dashes": [] };
Expand Down Expand Up @@ -179,6 +180,7 @@ export interface Response {
export type MethodPath = keyof Input;
/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = { "post /v1/test-with-dashes": true };
export const endpointTags = { "post /v1/test-with-dashes": [] };
Expand Down Expand Up @@ -300,6 +302,7 @@ export interface Response {
export type MethodPath = keyof Input;
/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = { "post /v1/test-with-dashes": true };
export const endpointTags = { "post /v1/test-with-dashes": [] };
Expand Down Expand Up @@ -777,6 +780,7 @@ export interface Response {
export type MethodPath = keyof Input;
/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = {
"get /v1/user/retrieve": true,
"patch /v1/user/:id": true,
Expand Down Expand Up @@ -1337,6 +1341,7 @@ export interface Response {
export type MethodPath = keyof Input;
/** @deprecated use content-type header of an actual response */
export const jsonEndpoints = { "post /v1/test-with-dashes": true };
export const endpointTags = { "post /v1/test-with-dashes": [] };
Expand Down
Loading

0 comments on commit a8bed37

Please sign in to comment.