io.swagger.codegen.ClientOptInput Java Examples
The following examples show how to use
io.swagger.codegen.ClientOptInput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodegenConfigurator.java From TypeScript-Microservices with MIT License | 4 votes |
public ClientOptInput toClientOptInput() { Validate.notEmpty(lang, "language must be specified"); Validate.notEmpty(inputSpec, "input spec must be specified"); setVerboseFlags(); setSystemProperties(); CodegenConfig config = CodegenConfigLoader.forName(lang); config.setInputSpec(inputSpec); config.setOutputDir(outputDir); config.setSkipOverwrite(skipOverwrite); config.setIgnoreFilePathOverride(ignoreFileOverride); config.setRemoveOperationIdPrefix(removeOperationIdPrefix); config.instantiationTypes().putAll(instantiationTypes); config.typeMapping().putAll(typeMappings); config.importMapping().putAll(importMappings); config.languageSpecificPrimitives().addAll(languageSpecificPrimitives); config.reservedWordsMappings().putAll(reservedWordMappings); checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE); checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE); checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE); checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID); checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID); checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION); checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR); checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX); checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX); checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID); checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID); checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE); checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT); handleDynamicProperties(config); if (isNotEmpty(library)) { config.setLibrary(library); } config.additionalProperties().putAll(additionalProperties); ClientOptInput input = new ClientOptInput() .config(config); final List<AuthorizationValue> authorizationValues = AuthParser.parse(auth); Swagger swagger = new SwaggerParser().read(inputSpec, authorizationValues, true); input.opts(new ClientOpts()) .swagger(swagger); return input; }
Example #2
Source File: IoCCodeGenerator.java From yang2swagger with Eclipse Public License 1.0 | 4 votes |
public static void main(String[] args) throws Exception { Guice.createInjector(new GeneratorInjector()); IoCSwaggerGenerator generator; if(args.length == 1) { // prepare a default generator for a given directory with YANG modules and accept all of them for path // generation generator = IoCGeneratorHelper.getGenerator(new File(args[0]),m -> true); } else { // prepare a default generator for all YANG modules and from classpath and accept only these which name // starts from 'tapi' generator = IoCGeneratorHelper.getGenerator(m -> m.getName().startsWith("Tapi")); } generator.tagGenerator(new SegmentTagGenerator()); // -------- configure path generator --------------- // for data tree generate only GET operations // generator.pathHandler(new PathHandlerBuilder().withoutFullCrud()); // for data tree generate full CRUD (depending on config flag in yang modules Swagger swagger = generator.generate(); JerseyServerCodegen codegenConfig = new JerseyServerCodegen(); // referencing handler for x-path annotation // codegenConfig.addAnnotation("propAnnotation", "x-path", v -> // "@com.mrv.provision.di.rest.jersey.metadata.Leafref(\"" + v + "\")" // ); ClientOpts clientOpts = new ClientOpts(); Path target = Files.createTempDirectory("generated"); codegenConfig.additionalProperties().put(CodegenConstants.API_PACKAGE, "com.mrv.provision.di.rest.jersey.tapi.api"); codegenConfig.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "com.mrv.provision.di.rest.jersey.tapi.model"); codegenConfig.setOutputDir(target.toString()); // write swagger.yaml to the target ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.writeValue(new FileWriter(new File(target.toFile(), "tapi.yaml")), swagger); ClientOptInput opts = new ClientOptInput().opts(clientOpts).swagger(swagger).config(codegenConfig); new DefaultGenerator() .opts(opts) .generate(); }
Example #3
Source File: SwaggerContext.java From sundrio with Apache License 2.0 | 4 votes |
public SwaggerContext(Swagger swagger, CodegenConfig config, ClientOptInput opts) { this.swagger = swagger; this.config = config; this.opts = opts; }
Example #4
Source File: SwaggerContext.java From sundrio with Apache License 2.0 | 4 votes |
public ClientOptInput getOpts() { return opts; }
Example #5
Source File: SundrioGenerator.java From sundrio with Apache License 2.0 | 4 votes |
public SundrioGenerator(ClientOptInput opts) { this.opts = opts; this.swagger = opts.getSwagger(); }
Example #6
Source File: SwaggerContextManager.java From sundrio with Apache License 2.0 | 4 votes |
public synchronized static SwaggerContext create(ClientOptInput opts) { context = new SwaggerContext(opts.getSwagger(), opts.getConfig(), opts); return context; }
Example #7
Source File: SwaggerContextManager.java From sundrio with Apache License 2.0 | 4 votes |
public synchronized static SwaggerContext create(Swagger swagger, CodegenConfig config, ClientOptInput opts) { context = new SwaggerContext(swagger, config, opts); return context; }