Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ public void process(Model m) throws IOException {
return; // we will be called again to handle the newly generated class.
if (new BeanClassGenerator(processingEnv).writeJava(m))
return; // we will be called again to handle the newly generated class.
if (new IncludeListClassGenerator(processingEnv).writeJava(m))
return; // we will be called again to handle the newly generated class.
new Schemas(processingEnv).writeXSD(m);
new KubernetesBootstrapper(processingEnv).boot(m);
new JsonSchemaGenerator(processingEnv).write(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,28 @@

import com.predic8.membrane.annot.Grammar;
import com.predic8.membrane.annot.yaml.GenericYamlParser;
import com.predic8.membrane.annot.yaml.WatchAction;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.List;

import static com.predic8.membrane.annot.yaml.WatchAction.ADDED;

/**
* This is the definition side of a {@link BeanRegistryImplementation}. You can start the bean registry
* and send it a series of change events.
*/
public interface BeanCollector {

default List<BeanDefinition> parseYamlBeanDefinitions(InputStream yamls, Grammar grammar) throws IOException {
List<BeanDefinition> bds = GenericYamlParser.parseMembraneResources(yamls, grammar);
return parseYamlBeanDefinitions(yamls, grammar, null);
}

default List<BeanDefinition> parseYamlBeanDefinitions(InputStream yamls, Grammar grammar, Path rootSourceFile) throws IOException {
List<BeanDefinition> bds = GenericYamlParser.parseMembraneResources(yamls, grammar, rootSourceFile);
for (BeanDefinition bd : bds) {
handle(new BeanDefinitionChanged(WatchAction.ADDED, bd), false);
handle(new BeanDefinitionChanged(ADDED, bd), false);
}
return bds;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* Copyright 2026 predic8 GmbH, www.predic8.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

package com.predic8.membrane.annot.generator;

import javax.annotation.processing.ProcessingEnvironment;

public class IncludeListClassGenerator extends ClassGenerator {

public IncludeListClassGenerator(ProcessingEnvironment processingEnv) {
super(processingEnv);
}

@Override
protected String getClassName() {
return "IncludeList";
}

@Override
protected String getClassImpl() {
return """
import com.predic8.membrane.annot.MCChildElement;
import com.predic8.membrane.annot.MCElement;

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

/**
* @description <p>
* Includes additional YAML configuration files before parsing the current file's own configuration.
* </p>
* <p>
* Include entries are resolved in the order they are listed. If an entry points to a directory,
* all matching <code>*.apis.yaml</code> / <code>*.apis.yml</code> files in that directory are included.
* For directory includes, no ordering is applied. Includes are resolved recursively and cyclic
* include chains are rejected.
* </p>
* <p>
* Paths used inside included configuration content (for example OpenAPI file locations or other
* referenced resources) are resolved against the base path of the main configuration file.
* </p>
* @yaml <pre><code>
* include:
* - "."
* - apis/demo.apis.yaml
* - other/apis
* </code></pre>
*/
@MCElement(name = "include", topLevel = true, noEnvelope = true, component = false)
public class IncludeList {

List<String> includes = new ArrayList<>();

/**
* @description <p>
* Declares include entries as a list of strings.
* </p>
* <p>
* Each string is a path to either a YAML file or a directory. Relative paths are resolved
* against the directory of the including file. Absolute paths are also supported.
* </p>
*/
@MCChildElement(allowForeign = true)
public void setInclude(List<String> include) {
this.includes = include;
}

public List<String> getInclude() {
return includes;
}

}
""";
}

}
Loading
Loading