-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
333 generated avro class imports use model package instead of avro sc…
…hema namespace (#335) * Logic changed in AsyncApiGenerator processExternalAvro function to always use Avro contained namespace. Test for file generation with external Avro schemas changed by adding new avro schema with namespace outside of the model package. * README.md changed to reflect new behaviour * Added new exception, InvalidAvroException, for the case where an Avro file contains no namespace attribute as well as a test for said exception in AsyncApiGeneratorTest, testExceptionForTestIssueInvalidAvro(). Also Updated README to reflect behaviour. * README changed to display correct version (5.3.6) * Changed version number from 5.3.6 to 5.4.0 * Readme column width fixed * Removed references to disashop present in some tests. Now the name referenced is testshop. * Added developer information to the pom file
- Loading branch information
1 parent
824fad3
commit fe2c468
Showing
22 changed files
with
390 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...c/main/java/com/sngular/api/generator/plugin/asyncapi/exception/InvalidAvroException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package com.sngular.api.generator.plugin.asyncapi.exception; | ||
|
||
public class InvalidAvroException extends RuntimeException { | ||
private static final String ERROR_MESSAGE = "AsyncApi -> Avro schema at path %s lacks a namespace."; | ||
public InvalidAvroException(final String enumName) { | ||
super(String.format(ERROR_MESSAGE, enumName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../resources/asyncapigenerator/testFileGenerationExternalAvro/assets/IPublishOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...syncapigenerator/testFileGenerationExternalAvro/assets/ISubscribeReceiptExternalAvro.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.sngular.scsplugin.externalavro.model.event.consumer; | ||
|
||
import com.sngular.testshop.commons.Receipt; | ||
|
||
public interface ISubscribeReceiptExternalAvro { | ||
|
||
void subscribeReceiptExternalAvro(final Receipt value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ngine/src/test/resources/asyncapigenerator/testFileGenerationExternalAvro/avro/Order.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ine/src/test/resources/asyncapigenerator/testFileGenerationExternalAvro/avro/Receipt.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"type": "record", | ||
"name": "Receipt", | ||
"namespace": "com.sngular.testshop.commons", | ||
"fields": [ | ||
{ | ||
"name": "ref", | ||
"type": "string" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...e/src/test/resources/asyncapigenerator/testIssueInvalidAvro/assets/IPublishOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.sngular.scsplugin.issueAvro.model.event.producer; | ||
|
||
import com.sngular.testshop.business_model.model.event.Order; | ||
|
||
public interface IPublishOperationExternalAvro { | ||
|
||
Order publishOperationExternalAvro(); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ources/asyncapigenerator/testIssueInvalidAvro/assets/ISubscribeOperationExternalAvro.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.sngular.scsplugin.issueAvro.model.event.consumer; | ||
|
||
import com.sngular.scsplugin.issueAvro.model.event.CreateOrder; | ||
|
||
public interface ISubscribeOperationExternalAvro { | ||
|
||
void subscribeOperationExternalAvro(final CreateOrder value); | ||
} |
10 changes: 10 additions & 0 deletions
10
...src/test/resources/asyncapigenerator/testIssueInvalidAvro/assets/ModelClassException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sngular.scsplugin.issueAvro.model.event.exception; | ||
|
||
public class ModelClassException extends RuntimeException { | ||
|
||
private static final String ERROR_MESSAGE = "There are some problems related to the entity called %s. Maybe could be caused by required fields or anyOf/oneOf restrictions"; | ||
|
||
public ModelClassException(final String modelEntity) { | ||
super(String.format(ERROR_MESSAGE, modelEntity)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...api-engine/src/test/resources/asyncapigenerator/testIssueInvalidAvro/assets/Producer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sngular.scsplugin.issueAvro.model.event.producer; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import com.sngular.testshop.business_model.model.event.Order; | ||
|
||
@Configuration | ||
public class Producer { | ||
|
||
private final IPublishOperationExternalAvro publishOperationExternalAvro; | ||
|
||
protected Producer(final IPublishOperationExternalAvro publishOperationExternalAvro) { | ||
this.publishOperationExternalAvro = publishOperationExternalAvro; | ||
} | ||
|
||
@Bean | ||
public Supplier<Order> publishOperationExternalAvro() { | ||
return () -> publishOperationExternalAvro.publishOperationExternalAvro(); | ||
} | ||
|
||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...i-engine/src/test/resources/asyncapigenerator/testIssueInvalidAvro/assets/Subscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sngular.scsplugin.issueAvro.model.event.consumer; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import com.sngular.scsplugin.issueAvro.model.event.CreateOrder; | ||
|
||
@Configuration | ||
public class Subscriber { | ||
|
||
private final ISubscribeOperationExternalAvro subscribeOperationExternalAvro; | ||
|
||
protected Subscriber(final ISubscribeOperationExternalAvro subscribeOperationExternalAvro) { | ||
this.subscribeOperationExternalAvro = subscribeOperationExternalAvro; | ||
} | ||
|
||
@Bean | ||
public Consumer<CreateOrder> subscribeOperationExternalAvro() { | ||
return value -> subscribeOperationExternalAvro.subscribeOperationExternalAvro(value); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.