Skip to content

Commit 38ea079

Browse files
committed
Release 1.1
using yang2swagger version 1.1.8
1 parent b8302fb commit 38ea079

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
<groupId>com.amartus.y2s</groupId>
88
<artifactId>yang2swagger-tapi-cli</artifactId>
9-
<version>1.0</version>
9+
<version>1.1</version>
1010
<properties>
11-
<y2s.version>1.1.7</y2s.version>
11+
<y2s.version>1.1.8</y2s.version>
1212
</properties>
1313

1414
<build>

src/main/java/com/amartus/y2s/Generator.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

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

70+
@Option(name = "-authentication", usage="Authentication definition")
71+
public AuthenticationMechanism authenticationMechanism = AuthenticationMechanism.NONE;
72+
7173
OutputStream out = System.out;
7274

75+
public enum AuthenticationMechanism {
76+
BASIC, NONE
77+
}
7378

7479
public enum ElementType {
7580
DATA, RPC, DATA_AND_RPC;
@@ -118,7 +123,12 @@ protected void generate() throws IOException, ReactorException {
118123
.format(outputFormat).consumes(contentType).produces(contentType)
119124
.host("localhost:1234").elements(map(elementType))
120125
.pathHandler(pathHandler)
121-
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"));
126+
.appendPostProcessor(new PathPrunner("/operations").withType("tapi.common.GlobalClass"))
127+
.appendPostProcessor(new CollapseTypes());
128+
129+
if(AuthenticationMechanism.BASIC.equals(authenticationMechanism)) {
130+
generator.appendPostProcessor(new AddSecurityDefinitions().withSecurityDefinition("api_sec", new BasicAuthDefinition()));
131+
}
122132

123133
if(simplified) {
124134
generator.appendPostProcessor(new SingleParentInheritenceModel());

0 commit comments

Comments
 (0)