Skip to content

Commit

Permalink
Release 1.1
Browse files Browse the repository at this point in the history
using yang2swagger version 1.1.8
  • Loading branch information
bartoszm committed May 14, 2018
1 parent b8302fb commit 38ea079
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<groupId>com.amartus.y2s</groupId>
<artifactId>yang2swagger-tapi-cli</artifactId>
<version>1.0</version>
<version>1.1</version>
<properties>
<y2s.version>1.1.7</y2s.version>
<y2s.version>1.1.8</y2s.version>
</properties>

<build>
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/com/amartus/y2s/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

import com.mrv.yangtools.codegen.SwaggerGenerator;
import com.mrv.yangtools.codegen.impl.path.rfc8040.PathHandlerBuilder;
import com.mrv.yangtools.codegen.impl.postprocessor.PathPrunner;
import com.mrv.yangtools.codegen.impl.postprocessor.RemoveUnusedDefinitions;
import com.mrv.yangtools.codegen.impl.postprocessor.SingleParentInheritenceModel;
import com.mrv.yangtools.codegen.impl.postprocessor.*;
import com.mrv.yangtools.common.ContextHelper;
import io.swagger.models.auth.BasicAuthDefinition;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
Expand Down Expand Up @@ -68,8 +67,14 @@ public class Generator {
@Option(name = "-use-namespaces", usage="Use namespaces in resource URI")
public boolean useNamespaces = false;

@Option(name = "-authentication", usage="Authentication definition")
public AuthenticationMechanism authenticationMechanism = AuthenticationMechanism.NONE;

OutputStream out = System.out;

public enum AuthenticationMechanism {
BASIC, NONE
}

public enum ElementType {
DATA, RPC, DATA_AND_RPC;
Expand Down Expand Up @@ -118,7 +123,12 @@ protected void generate() throws IOException, ReactorException {
.format(outputFormat).consumes(contentType).produces(contentType)
.host("localhost:1234").elements(map(elementType))
.pathHandler(pathHandler)
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"));
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"))
.appendPostProcessor(new CollapseTypes());

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

if(simplified) {
generator.appendPostProcessor(new SingleParentInheritenceModel());
Expand Down

0 comments on commit 38ea079

Please sign in to comment.