|
103 | 103 | """ |
104 | 104 |
|
105 | 105 |
|
| 106 | +TEMPLATE_CONTROL_INPUT_WITHOUT_UNSTABLE_TYPE_COMMENT = """/* |
| 107 | + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. |
| 108 | + */ |
| 109 | +
|
| 110 | +export type TemplateControlInput = {}; |
| 111 | +""" |
| 112 | + |
| 113 | + |
| 114 | +TEMPLATE_CONTROL_INPUT_WITH_UNSTABLE_TYPE_COMMENT = """/* |
| 115 | + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. |
| 116 | + */ |
| 117 | +
|
| 118 | +/** |
| 119 | + * Template-backed input payload for control create/update requests. |
| 120 | + */ |
| 121 | +export type TemplateControlInput = {}; |
| 122 | +""" |
| 123 | + |
| 124 | + |
106 | 125 | def _write_schema(tmp_path: Path, *, include_context_fields: bool) -> Path: |
107 | 126 | properties: dict[str, object] = { |
108 | 127 | "loc": {"type": "array"}, |
@@ -140,6 +159,10 @@ def _write_generated_file(tmp_path: Path) -> Path: |
140 | 159 | lib_dir.mkdir(parents=True) |
141 | 160 | file_path = models_dir / "validation-error.ts" |
142 | 161 | file_path.write_text(VALIDATION_ERROR_WITH_CONTEXT, encoding="utf-8") |
| 162 | + (models_dir / "template-control-input.ts").write_text( |
| 163 | + TEMPLATE_CONTROL_INPUT_WITHOUT_UNSTABLE_TYPE_COMMENT, |
| 164 | + encoding="utf-8", |
| 165 | + ) |
143 | 166 | (lib_dir / "config.ts").write_text(CONFIG_WITH_VERSIONED_METADATA, encoding="utf-8") |
144 | 167 | return generated_dir |
145 | 168 |
|
@@ -212,3 +235,30 @@ def test_normalizer_rewrites_sdk_metadata_to_stable_version(tmp_path: Path) -> N |
212 | 235 | 'userAgent: "speakeasy-sdk/typescript 0.1.0 2.827.0 0.0.0 agent-control"' |
213 | 236 | in normalized |
214 | 237 | ) |
| 238 | + |
| 239 | + |
| 240 | +def test_normalizer_removes_unstable_template_control_input_type_comment( |
| 241 | + tmp_path: Path, |
| 242 | +) -> None: |
| 243 | + schema_path = _write_schema(tmp_path, include_context_fields=True) |
| 244 | + generated_dir = _write_generated_file(tmp_path) |
| 245 | + template_control_input = generated_dir / "models" / "template-control-input.ts" |
| 246 | + template_control_input.write_text( |
| 247 | + TEMPLATE_CONTROL_INPUT_WITH_UNSTABLE_TYPE_COMMENT, |
| 248 | + encoding="utf-8", |
| 249 | + ) |
| 250 | + |
| 251 | + subprocess.run( |
| 252 | + [ |
| 253 | + sys.executable, |
| 254 | + str(SCRIPT_PATH), |
| 255 | + "--schema", |
| 256 | + str(schema_path), |
| 257 | + "--generated-dir", |
| 258 | + str(generated_dir), |
| 259 | + ], |
| 260 | + check=True, |
| 261 | + ) |
| 262 | + |
| 263 | + normalized = template_control_input.read_text(encoding="utf-8") |
| 264 | + assert normalized == TEMPLATE_CONTROL_INPUT_WITHOUT_UNSTABLE_TYPE_COMMENT |
0 commit comments