Skip to content

YAML Property completion: Superclass properties not detected in case of List or Map #449

Closed
@beckermarc

Description

@beckermarc

Hi,

I am using Spring Boot Tools 1.16.0 in VS Code. I am observing a problem with property completion in application.yaml files, that occurs whenever a property (bar) is defined in a superclass (SuperclassProperties) of a type (NestedProperties), that can be provided as a List or Map (nested). The property (bar) is not found in that case and reported as invalid, only properties defined in the child class (foo) work correctly.

If the property nested is not defined as a list or map (private NestedProperties nested), the
bar property is explicitly listed in the spring-configuration-metadata.json file and code-completion works as expected.

Example:

package my.property.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("myprops")
public class TestProperties {

	private List<NestedProperties> nested = new ArrayList<>();

	public List<NestedProperties> getNested() {
		return nested;
	}

	public void setNested(List<NestedProperties> nested) {
		this.nested = nested;
	}

	public static class NestedProperties extends SuperclassProperties {

		private String foo;

		public String getFoo() {
			return foo;
		}

		public void setFoo(String foo) {
			this.foo = foo;
		}

	}

	public static class SuperclassProperties {

		private String bar;

		public String getBar() {
			return bar;
		}

		public void setBar(String bar) {
			this.bar = bar;
		}

	}

}
{
  "groups": [
    {
      "name": "myprops",
      "type": "my.property.test.TestProperties",
      "sourceType": "my.property.test.TestProperties"
    }
  ],
  "properties": [
    {
      "name": "myprops.nested",
      "type": "java.util.List<my.property.test.TestProperties$NestedProperties>",
      "sourceType": "my.property.test.TestProperties"
    }
  ],
  "hints": []
}

As you can see, only foo is suggested, but not bar:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions