Skip to content

Commit

Permalink
Adding option for generating path for GlobalClass only - default disa…
Browse files Browse the repository at this point in the history
…bled

Signed-off-by: bmichalik <[email protected]>
  • Loading branch information
bartoszm committed Oct 5, 2018
1 parent f6090a4 commit 8f89222
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.amartus.y2s</groupId>
<artifactId>yang2swagger-tapi-cli</artifactId>
<version>1.3.1</version>
<version>1.4</version>
<properties>
<y2s.version>1.1.10</y2s.version>
</properties>
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/com/amartus/y2s/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public class Generator {
@Option(name = "-fullCrud", usage="If the flag is set to false path are generated for GET operations only. Default true")
public boolean fullCrud = true;

@Option(name = "-generate-for-global-class", usage="Generate resource URL only for GlobalClass nodels. Default false")
public boolean forGlobalClass = false;

OutputStream out = System.out;

public enum AuthenticationMechanism {
Expand Down Expand Up @@ -129,9 +132,15 @@ protected void generate() throws IOException, ReactorException {
.version(apiVersion)
.format(outputFormat).consumes(contentType).produces(contentType)
.host("localhost:1234").elements(map(elementType))
.pathHandler(pathHandler)
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"))
.appendPostProcessor(new CollapseTypes());
.pathHandler(pathHandler);


if(forGlobalClass) {
generator
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"));
}
generator
.appendPostProcessor(new CollapseTypes());

if(AuthenticationMechanism.BASIC.equals(authenticationMechanism)) {
generator.appendPostProcessor(new AddSecurityDefinitions().withSecurityDefinition("api_sec", new BasicAuthDefinition()));
Expand Down

0 comments on commit 8f89222

Please sign in to comment.