Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add generated annotation #323

Merged
merged 8 commits into from
Oct 2, 2023
Merged
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
2 changes: 2 additions & 0 deletions filters/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ function addBackSlashToPattern(val) {
return result;
}
filter.addBackSlashToPattern = addBackSlashToPattern;

filter.currentTime = () => (new Date(Date.now())).toISOString();
3 changes: 3 additions & 0 deletions partials/AmqpConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.messaging.MessageChannel;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
public class Config {

Expand Down
3 changes: 3 additions & 0 deletions partials/CommonPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.MessagingGateway;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@MessagingGateway
public interface PublisherService {

Expand Down
2 changes: 2 additions & 0 deletions partials/KafkaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@
import org.springframework.kafka.support.serializer.JsonDeserializer;
import org.springframework.kafka.support.serializer.JsonSerializer;

import javax.annotation.processing.Generated;
import java.util.HashMap;
import java.util.Map;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
{% if hasPublish %}@EnableKafka{% endif %}
public class Config {
Expand Down
2 changes: 2 additions & 0 deletions partials/KafkaPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
{%- endfor -%}
{% endif -%}
{% endfor %}
import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Service
public class PublisherService {

Expand Down
3 changes: 3 additions & 0 deletions partials/MqttConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import org.springframework.messaging.MessageHandler;
import org.springframework.util.StringUtils;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
public class Config {

Expand Down
3 changes: 3 additions & 0 deletions template/src/main/java/com/asyncapi/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@SpringBootApplication
public class Application {

Expand Down
2 changes: 2 additions & 0 deletions template/src/main/java/com/asyncapi/model/$$message$$.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package {{ params['userJavaPackage'] }}.model;

import javax.annotation.processing.Generated;
{% if params.springBoot2 -%}
import javax.validation.Valid;
{% else %}
Expand All @@ -12,6 +13,7 @@
* {{ line | safe}}{% endfor %}{% if message.examples() %}
* Examples: {{message.examples() | examplesToString | safe}}{% endif %}
*/{% endif %}
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
public class {{messageName | camelCase | upperFirst}} {
{%- if message.payload().anyOf() or message.payload().oneOf() %}
{%- set payloadName = 'OneOf' %}{%- set hasPrimitive = false %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;

{% if schema.description() or schema.examples() %}/**{% for line in schema.description() | splitByLines %}
* {{ line | safe}}{% endfor %}{% if schema.examples() %}
* Examples: {{schema.examples() | examplesToString | safe}}{% endif %}
*/{% endif %}
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
public class {{schemaName | camelCase | upperFirst}} {
{% for propName, prop in schema.properties() %}
{%- set isRequired = propName | isRequired(schema.required()) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.processing.Generated;
import java.util.Random;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Component
public class CommandLinePublisher implements CommandLineRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
{%- endif %}
{%- endfor %}
{% endif %}
import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Service
public class MessageHandlerService {

Expand Down
3 changes: 3 additions & 0 deletions template/src/test/java/com/asyncapi/ApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {
Expand Down
2 changes: 2 additions & 0 deletions template/src/test/java/com/asyncapi/SimpleKafkaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -51,6 +52,7 @@
/**
* Example of tests for kafka based on spring-kafka-test library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class SimpleKafkaTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.shaded.com.google.common.collect.Lists;

import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.*;

Expand All @@ -51,6 +52,7 @@
/**
* Example of tests for kafka based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerKafkaTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.GenericContainer;

import javax.annotation.processing.Generated;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
Expand All @@ -40,6 +41,7 @@
/**
* Example of tests for mqtt based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerMqttTest {
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/additional-formats.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;


@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class SongPayload {

private @Valid java.util.UUID id;
Expand Down
13 changes: 13 additions & 0 deletions tests/__snapshots__/kafka.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import org.springframework.kafka.support.serializer.JsonDeserializer;
import org.springframework.kafka.support.serializer.JsonSerializer;

import javax.annotation.processing.Generated;
import java.util.HashMap;
import java.util.Map;

@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Configuration
@EnableKafka
public class Config {
Expand Down Expand Up @@ -104,7 +106,9 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import com.asyncapi.model.LightMeasuredPayload;
import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Service
public class PublisherService {

Expand Down Expand Up @@ -138,6 +142,9 @@ import org.springframework.messaging.handler.annotation.Payload;

import com.asyncapi.model.LightMeasuredPayload;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Service
public class MessageHandlerService {

Expand Down Expand Up @@ -169,10 +176,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;


@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class LightMeasuredPayload {

private @Valid Integer lumens;
Expand Down Expand Up @@ -250,12 +259,14 @@ public class LightMeasuredPayload {
exports[`template integration tests for generated files using the generator and mqtt example should generate proper config, services and DTOs files for provided kafka 5`] = `
"package com.asyncapi.model;

import javax.annotation.processing.Generated;

import jakarta.validation.Valid;
import java.util.Objects;
import java.util.List;


@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class LightMeasured {
private @Valid LightMeasuredPayload payload;

Expand Down Expand Up @@ -335,6 +346,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.shaded.com.google.common.collect.Lists;

import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.*;

Expand All @@ -347,6 +359,7 @@ import static org.junit.Assert.assertNotEquals;
/**
* Example of tests for kafka based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerKafkaTest {
Expand Down
Loading