diff --git a/rewrite-javascript/rewrite/src/recipe.ts b/rewrite-javascript/rewrite/src/recipe.ts index c63b5dc4dd5..cb2cc059f65 100644 --- a/rewrite-javascript/rewrite/src/recipe.ts +++ b/rewrite-javascript/rewrite/src/recipe.ts @@ -96,14 +96,18 @@ export abstract class Recipe { description: this.description, tags: this.tags, estimatedEffortPerOccurrence: this.estimatedEffortPerOccurrence, - recipeList: await mapAsync(await this.recipeList(), async r => r.descriptor()), options: Object.entries(optionsRecord).map(([key, descriptor]) => ({ name: key, value: (this as any)[key], required: descriptor.required ?? true, ...descriptor })), - dataTables: this.dataTables + preconditions: [], + recipeList: await mapAsync(await this.recipeList(), async r => r.descriptor()), + dataTables: this.dataTables, + maintainers: [], + contributors: [], + examples: [] } } @@ -135,9 +139,13 @@ export interface RecipeDescriptor { readonly description: string readonly tags: string[] readonly estimatedEffortPerOccurrence: Minutes - readonly recipeList: RecipeDescriptor[] readonly options: ({ name: string, value?: any } & OptionDescriptor)[] + readonly preconditions: RecipeDescriptor[] + readonly recipeList: RecipeDescriptor[] readonly dataTables: DataTableDescriptor[] + readonly maintainers: any[] + readonly contributors: any[] + readonly examples: any[] } export interface OptionDescriptor { diff --git a/rewrite-javascript/rewrite/test/recipe.test.ts b/rewrite-javascript/rewrite/test/recipe.test.ts index 45346f7df21..350e735f07c 100644 --- a/rewrite-javascript/rewrite/test/recipe.test.ts +++ b/rewrite-javascript/rewrite/test/recipe.test.ts @@ -43,9 +43,13 @@ describe("recipes", () => { value: undefined } ], + preconditions: [], recipeList: [], tags: [], - dataTables: [] + dataTables: [], + maintainers: [], + contributors: [], + examples: [] }); }); }); diff --git a/rewrite-python/rewrite/src/rewrite/rpc/server.py b/rewrite-python/rewrite/src/rewrite/rpc/server.py index 67927082c64..b64302471ef 100644 --- a/rewrite-python/rewrite/src/rewrite/rpc/server.py +++ b/rewrite-python/rewrite/src/rewrite/rpc/server.py @@ -897,8 +897,12 @@ def _recipe_descriptor_to_dict(descriptor) -> dict: } for name, value, opt in descriptor.options ], - 'dataTables': descriptor.data_tables, + 'preconditions': [], 'recipeList': [_recipe_descriptor_to_dict(r) for r in descriptor.recipe_list], + 'dataTables': descriptor.data_tables, + 'maintainers': [], + 'contributors': [], + 'examples': [], } diff --git a/rewrite-python/rewrite/tests/rpc/test_server.py b/rewrite-python/rewrite/tests/rpc/test_server.py index 0c4f3ddfed0..cf2ce222f5b 100644 --- a/rewrite-python/rewrite/tests/rpc/test_server.py +++ b/rewrite-python/rewrite/tests/rpc/test_server.py @@ -24,3 +24,26 @@ def fake_parse_python_source(source, path="", relative_to=None, ty_clie assert observed["source"] == "" assert observed["path"] == str(tmp_path / "pkg" / "__init__.py") assert (tmp_path / "pkg" / "__init__.py").read_text(encoding="utf-8") == "" + + +def test_recipe_descriptor_to_dict_emits_all_collection_keys(): + from rewrite.recipe import RecipeDescriptor + from rewrite.rpc.server import _recipe_descriptor_to_dict + + descriptor = RecipeDescriptor( + name="org.example.Foo", + display_name="Foo", + description="A recipe.", + tags=[], + estimated_effort_per_occurrence=0, + options=[], + data_tables=[], + recipe_list=[], + ) + + result = _recipe_descriptor_to_dict(descriptor) + + for key in ("tags", "options", "preconditions", "recipeList", + "dataTables", "maintainers", "contributors", "examples"): + assert key in result, f"missing key: {key}" + assert result[key] == [], f"{key} should be empty list, got {result[key]!r}"