Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
d28717c
add first examples
christiangoerdes Nov 7, 2025
ed35986
add examples (-loadbalancing)
christiangoerdes Nov 7, 2025
8c3f145
add examples (-openapi)
christiangoerdes Nov 7, 2025
783cd3b
add examples (-orchestration)
christiangoerdes Nov 7, 2025
cfe4bd4
add examples (-route-traffic)
christiangoerdes Nov 10, 2025
af80eb9
add examples (-security/ntlm)
christiangoerdes Nov 11, 2025
3bc9d67
Merge branch 'master' into yaml-examples
christiangoerdes Nov 11, 2025
1dac627
add examples (-security/oauth2/google)
christiangoerdes Nov 11, 2025
5545102
Merge branch 'master' into yaml-examples
predic8 Nov 11, 2025
8492220
add examples (-security)
christiangoerdes Nov 12, 2025
76f028a
Merge remote-tracking branch 'origin/yaml-examples' into yaml-examples
christiangoerdes Nov 12, 2025
ab92dbf
add examples (-websockets)
christiangoerdes Nov 12, 2025
037afeb
add examples (done)
christiangoerdes Nov 12, 2025
755d84c
Rename and fix yaml example test
christiangoerdes Nov 13, 2025
8431fdd
Merge branch 'master' into yaml-examples
christiangoerdes Nov 18, 2025
321e5b6
schema validation, moved BeanCache from core to annot
rrayst Nov 19, 2025
83141e0
working 'annot' tests
rrayst Nov 19, 2025
6bcb264
fixed Router initialization
rrayst Nov 19, 2025
619b57d
removed exception declaration
rrayst Nov 20, 2025
2ebc6a7
added child test
rrayst Nov 20, 2025
c1cc5e7
added attribute test
rrayst Nov 20, 2025
f2c677b
Add YamlSetterConflictTest
christiangoerdes Nov 20, 2025
adfe8e1
use multiline string
christiangoerdes Nov 21, 2025
0e50c1a
adde test
rrayst Nov 21, 2025
267074c
added more tests
rrayst Nov 21, 2025
274d696
code improvements
christiangoerdes Nov 21, 2025
028a014
add documentation
christiangoerdes Nov 21, 2025
bb104ac
fixed child element parsing where child element name is also name of …
rrayst Nov 21, 2025
34f84ba
Merge branch 'yaml-bean-registry' of https://github.com/membrane/serv…
rrayst Nov 21, 2025
5a36b84
imoprove
christiangoerdes Nov 21, 2025
933bcec
Merge branch 'yaml-bean-registry' into yaml-examples
christiangoerdes Nov 21, 2025
efb4174
fix examples
christiangoerdes Nov 21, 2025
18e16fe
switch spec to api
christiangoerdes Nov 21, 2025
98ea979
fixes
christiangoerdes Nov 21, 2025
b152dc2
spec -> api
christiangoerdes Nov 21, 2025
abb8640
Add Yaml examples (#2346)
christiangoerdes Nov 21, 2025
7d8883d
Merge remote-tracking branch 'origin/yaml-bean-registry' into yaml-be…
christiangoerdes Nov 21, 2025
be418cc
Merge branch 'master' into yaml-bean-registry
christiangoerdes Nov 21, 2025
c261f55
Merge branch 'master' into yaml-bean-registry
christiangoerdes Nov 21, 2025
5fba8ca
close InputStream
rrayst Nov 21, 2025
2e63545
smaller improvements
rrayst Nov 22, 2025
73a08ed
added line numbers to parsing
rrayst Nov 22, 2025
5c48dd3
minor improvements
rrayst Nov 23, 2025
04a1f4d
spec -> api
christiangoerdes Nov 24, 2025
025c994
fix and add schema comment
christiangoerdes Nov 24, 2025
b59f498
fixes
christiangoerdes Nov 24, 2025
a6a1903
fixed examples/tests
christiangoerdes Nov 25, 2025
32188cd
yaml parsing: rm newline from string
christiangoerdes Nov 25, 2025
7f6ce75
fix tests
christiangoerdes Nov 25, 2025
1ed6e55
fix tests
christiangoerdes Nov 25, 2025
9b3c702
Merge remote-tracking branch 'origin/yaml-bean-registry' into yaml-be…
christiangoerdes Nov 25, 2025
61d8d55
fix examples
christiangoerdes Nov 25, 2025
ca2b508
add missing conf element
christiangoerdes Nov 26, 2025
e03b85e
rm apis.yaml
christiangoerdes Nov 26, 2025
42e1a24
add apis.yaml to .gitignore
christiangoerdes Nov 26, 2025
d30a45e
enable additionalProperties when MCOtherAttributes is set
christiangoerdes Nov 27, 2025
f360a8e
add non top-level id setter to schema (e.g. for ClaimList.Scope)
christiangoerdes Nov 27, 2025
92df3ec
improve (see coderabbitai)
christiangoerdes Nov 27, 2025
e27cd14
fix toplevel properties
christiangoerdes Nov 27, 2025
8c4f139
fix test and improve error
christiangoerdes Nov 27, 2025
6ff9193
fix JSONYAMLSchemaValidator json parsing
christiangoerdes Nov 27, 2025
b2e8cfe
fix Yaml initialization order
christiangoerdes Nov 27, 2025
133ebc3
rm getParentProxy()
christiangoerdes Nov 27, 2025
cac392b
add ProxyAware interface
christiangoerdes Nov 27, 2025
1d94bb1
add LiCENSE
christiangoerdes Nov 27, 2025
7a65aa4
fix setProxy for nested elements
christiangoerdes Nov 27, 2025
52a5adf
coderabbitai changes
christiangoerdes Nov 27, 2025
97b1e18
eliminate double unmarshalling
rrayst Nov 27, 2025
c0f38d6
Make tests tolerate 404 responses due to inconsistent external servic…
christiangoerdes Nov 28, 2025
5b907cc
fix test
christiangoerdes Nov 28, 2025
254a48b
update pom for jackson 3.0
christiangoerdes Nov 28, 2025
280673a
upgrade to jackson 3.0 (WIP)
christiangoerdes Nov 28, 2025
d0aaa2f
upgrade to jackson 3.0 (WIP)
christiangoerdes Nov 28, 2025
113955b
upgrade to jackson 3.0 (WIP)
christiangoerdes Nov 28, 2025
f17612f
upgrade to jackson 3.0 (WIP)
christiangoerdes Nov 28, 2025
50fb10c
upgrade to jackson 3.0 (WIP)
christiangoerdes Nov 28, 2025
934a638
upgrade to jackson 3.0 (builds)
christiangoerdes Nov 28, 2025
fc85902
fixes
christiangoerdes Nov 28, 2025
3d82cad
down to 282 UnitTest failures
christiangoerdes Nov 28, 2025
155fcb1
down to 160 UnitTest failures
christiangoerdes Nov 28, 2025
3808c98
jackson 3.0 fixes
christiangoerdes Dec 1, 2025
7d766aa
jackson 3.0 fixes
christiangoerdes Dec 1, 2025
4afde86
fix test
russelmrcl Dec 1, 2025
2d37939
added comment
rrayst Dec 1, 2025
e384a7c
Merge branch 'yaml-bean-registry' of https://github.com/membrane/serv…
rrayst Dec 1, 2025
1fc2745
jackson 3.0 fixes
christiangoerdes Dec 1, 2025
c969415
all unit tests pass
christiangoerdes Dec 1, 2025
e87149e
refactor: minor
predic8 Dec 1, 2025
761c2f4
use ParsingContext
christiangoerdes Dec 1, 2025
16215eb
extract MethodSetter
christiangoerdes Dec 1, 2025
33599ec
extract NodeValidationUtils
christiangoerdes Dec 2, 2025
82b50f3
refactoring
christiangoerdes Dec 2, 2025
4114d8b
refactoring
christiangoerdes Dec 2, 2025
fc63411
Merge remote-tracking branch 'origin/yaml-bean-registry' into yaml-be…
christiangoerdes Dec 2, 2025
d2d094d
Merge branch 'master' into yaml-bean-registry
christiangoerdes Dec 2, 2025
8f5b9a9
refactoring
christiangoerdes Dec 2, 2025
f58f8b2
Merge remote-tracking branch 'origin/yaml-bean-registry' into yaml-be…
christiangoerdes Dec 2, 2025
525fe99
add comments and rename K8sHelperGenerator.java to Grammar
christiangoerdes Dec 2, 2025
c13d212
fix
christiangoerdes Dec 2, 2025
d9dc404
rename fixes
christiangoerdes Dec 2, 2025
8a130c7
fix wrong context for structured setter
christiangoerdes Dec 2, 2025
0ba7bc2
Merge branch 'yaml-bean-registry' into jackson-3.0-upgrade
christiangoerdes Dec 2, 2025
7ecc227
fix merge errors
christiangoerdes Dec 2, 2025
f0c35c1
refactor: minor
predic8 Dec 2, 2025
4ff1711
minor: refactoring
predic8 Dec 3, 2025
63bdad8
minor: refactoring
predic8 Dec 3, 2025
32b06eb
minor: refactoring
predic8 Dec 3, 2025
ae9ac88
minor: refactoring
predic8 Dec 3, 2025
022108c
minor: refactoring
predic8 Dec 3, 2025
3020727
fix: yaml parsing tests
predic8 Dec 3, 2025
bed3e49
fix: yaml parsing tests
predic8 Dec 3, 2025
d0089ca
refactor: minor
predic8 Dec 3, 2025
e9e166f
refactor: minor
predic8 Dec 3, 2025
7ed0077
refactor: minor
predic8 Dec 3, 2025
ba49c68
Merge branch 'yaml-bean-registry' into jackson-3.0-upgrade
christiangoerdes Dec 4, 2025
f431c7d
merge fix
christiangoerdes Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ maven-plugin/target/surefire/
/docs/router-conf.xsd
.vscode/
/core/derby.log
/distribution/conf/apis.yaml
17 changes: 0 additions & 17 deletions .run/IDEStarter.run.xml

This file was deleted.

6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ Solve even complex custom API requirements with simple configurations.

**YAML Configuration (beta):**
```yaml
apiVersion: membrane-api.io/v1beta2
kind: api
metadata:
name: log
spec:
api:
port: 2000
interceptors:
- log:
Expand Down
19 changes: 12 additions & 7 deletions annot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,24 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>tools.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
Expand Down
39 changes: 23 additions & 16 deletions annot/src/main/java/com/predic8/membrane/annot/AbstractParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.HashSet;
import java.util.Set;

import org.jetbrains.annotations.*;
import org.slf4j.*;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.RuntimeBeanNameReference;
Expand All @@ -36,10 +38,11 @@

public abstract class AbstractParser extends AbstractSingleBeanDefinitionParser {

private static final String MEMBRANE_BEANS_NAMESPACE = "http://membrane-soa.org/proxies/1/";
private static final Logger log = LoggerFactory.getLogger(AbstractParser.class);

private static final String MEMBRANE_PROXIES_NAMESPACE = "http://membrane-soa.org/proxies/1/";

private boolean inlined = false;
private boolean inlined = false;

public BeanDefinition parse(Element e) {
inlined = true;
Expand Down Expand Up @@ -112,6 +115,7 @@ protected void setProperties(String prop, Element e, BeanDefinitionBuilder build
builder.addPropertyValue(prop, attrs);
}

// TODO @Tobias can that be deleted?
protected void parseElementToProperty(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder, String property) {
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();

Expand Down Expand Up @@ -143,32 +147,35 @@ protected void handleChildElement(Element ele, ParserContext parserContext, Bean

try {
Object o = delegate.parsePropertySubElement(ele, builder.getBeanDefinition());

String clazz = null;
if (o instanceof BeanDefinitionHolder) {
clazz = ((BeanDefinitionHolder) o).getBeanDefinition().getBeanClassName();
} else if (o instanceof RuntimeBeanReference) {
clazz = parserContext.getRegistry().getBeanDefinition(((RuntimeBeanReference) o).getBeanName()).getBeanClassName();
} else if (o instanceof RuntimeBeanNameReference) {
clazz = parserContext.getRegistry().getBeanDefinition(((RuntimeBeanNameReference) o).getBeanName()).getBeanClassName();
} else {
parserContext.getReaderContext().error("Don't know how to get bean class from " + o.getClass(), ele);
}

handleChildObject(ele, parserContext, builder, Class.forName(clazz), o);
handleChildObject(ele, parserContext, builder, Thread.currentThread().getContextClassLoader().loadClass(getBeanClassNameFromObject(ele, parserContext, o)), o);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}

protected int incrementCounter(BeanDefinitionBuilder builder, String counter) {
private static @Nullable String getBeanClassNameFromObject(Element ele, ParserContext parserContext, Object o) {
return switch (o) {
case BeanDefinitionHolder beanDefinitionHolder -> beanDefinitionHolder.getBeanDefinition().getBeanClassName();
case RuntimeBeanReference runtimeBeanReference -> parserContext.getRegistry().getBeanDefinition(runtimeBeanReference.getBeanName()).getBeanClassName();
case RuntimeBeanNameReference runtimeBeanNameReference -> parserContext.getRegistry().getBeanDefinition(runtimeBeanNameReference.getBeanName()).getBeanClassName();
default -> {
var msg = "Don't know how to get bean class from " + o.getClass();
log.warn(msg);
parserContext.getReaderContext().error(msg, ele);
throw new RuntimeException(msg);
}
};
}

protected int incrementCounter(BeanDefinitionBuilder builder, String counter) {
Integer i = (Integer) builder.getRawBeanDefinition().getAttribute(counter);
if (i == null)
i = 0;
builder.getRawBeanDefinition().setAttribute(counter, i+1);
return i;
}

// TODO needed?
protected boolean isMembraneNamespace(String namespace) {
return MEMBRANE_PROXIES_NAMESPACE.equals(namespace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

import java.util.List;

public interface K8sHelperGenerator {
public interface Grammar {

Class<?> getElement(String key);

Class<?> getLocal(String context, String key);

List<String> getCrdSingularNames();

String getSchemaLocation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
limitations under the License. */
package com.predic8.membrane.annot.generator;

import com.fasterxml.jackson.databind.node.*;
import tools.jackson.databind.node.*;
import com.predic8.membrane.annot.*;
import com.predic8.membrane.annot.generator.kubernetes.*;
import com.predic8.membrane.annot.generator.kubernetes.model.*;
Expand All @@ -37,7 +37,7 @@
* - Choose/cases/case has one nesting to much
* - apiKey/extractors/expressionExtractor/expression => too much?
*/
public class JsonSchemaGenerator extends AbstractK8sGenerator {
public class JsonSchemaGenerator extends AbstractGrammar {

private final Map<String, Boolean> topLevelAdded = new HashMap<>();

Expand Down Expand Up @@ -78,71 +78,33 @@ private void assemble(Model m, MainInfo main) throws IOException {
topLevelAdded.clear();

addParserDefinitions(m, main);
addTopLevelProperties();
addTopLevelProperties(m, main);

writeSchema(main, schema);
}

private void addTopLevelProperties() {
schema.additionalProperties(false)
.property(ref("soapProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_SoapProxyParser"))
.property(ref("internal")
.ref("#/$defs/com_predic8_membrane_core_config_spring_InternalParser"))
.property(ref("proxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_ProxyParser"))
.property(ref("api")
.ref("#/$defs/com_predic8_membrane_core_config_spring_ApiParser"))
.property(ref("stompProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_StompProxyParser"))
.property(ref("sslProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_SslProxyParser"));

List<SchemaObject> kinds = new ArrayList<>();

kinds.add(object()
.additionalProperties(false)
.property(ref("api")
.ref("#/$defs/com_predic8_membrane_core_config_spring_ApiParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("soapProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_SoapProxyParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("internal")
.ref("#/$defs/com_predic8_membrane_core_config_spring_InternalParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("proxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_ProxyParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("stompProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_StompProxyParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("sslProxy")
.ref("#/$defs/com_predic8_membrane_core_config_spring_SslProxyParser")
.required(true)));

kinds.add(object()
.additionalProperties(false)
.property(ref("bean")
.ref("#/$defs/com_predic8_membrane_core_config_spring_BeanParser")
.required(true)));

schema.oneOf(new ArrayList<>(kinds));
private void addTopLevelProperties(Model m, MainInfo main) {
schema.additionalProperties(false);
List<AbstractSchema<?>> kinds = new ArrayList<>();

main.getElements().values().forEach(e -> {
if (!e.getAnnotation().topLevel())
return;

String name = e.getAnnotation().name();
String refName = "#/$defs/" + e.getXSDTypeName(m);

schema.property(ref(name).ref(refName));

kinds.add(object()
.additionalProperties(false)
.property(ref(name)
.ref(refName)
.required(true)));
});

if (!kinds.isEmpty())
schema.oneOf(kinds);
}

private void addParserDefinitions(Model m, MainInfo main) {
Expand Down Expand Up @@ -180,7 +142,7 @@ private SchemaObject createParser(Model m, MainInfo main, ElementInfo elementInf
}

SchemaObject parser = object(parserName)
.additionalProperties(false)
.additionalProperties(elementInfo.getOai() != null)
.description(getDescriptionContent(elementInfo));
collectProperties(m, main, elementInfo, parser);
return parser;
Expand All @@ -203,16 +165,20 @@ private FileObject createFile(MainInfo main) throws IOException {
return processingEnv.getFiler()
.createResource(
CLASS_OUTPUT,
"com.predic8.membrane.core.config.json",
main.getAnnotation().outputPackage().replaceAll("\\.spring$", ".json"),
"membrane.schema.json",
sources.toArray(new Element[0])
);
}

private void processMCAttributes(ElementInfo i, SchemaObject so) {
i.getAis().stream()
.filter(ai -> !ai.getXMLName().equals("id"))
.forEach(ai -> so.property(createProperty(ai)));
i.getAis().forEach(ai -> {
// hide id only on top-level elements
if ("id".equals(ai.getXMLName()) && i.getAnnotation().topLevel()) {
return;
}
so.property(createProperty(ai));
});
}

private AbstractSchema<?> createProperty(AttributeInfo ai) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* Bundles functionality for kubernetes file generation
*/
public abstract class AbstractK8sGenerator {
public abstract class AbstractGrammar {

protected final ObjectMapper om = new ObjectMapper();
protected final ObjectWriter writer = om.writerWithDefaultPrettyPrinter();
Expand All @@ -53,7 +53,7 @@ public WritableNames(ElementInfo ei) {
}
}

public AbstractK8sGenerator(final ProcessingEnvironment processingEnv) {
public AbstractGrammar(final ProcessingEnvironment processingEnv) {
this.processingEnv = processingEnv;
}

Expand Down
Loading