io.swagger.codegen.CodegenConfig Java Examples
The following examples show how to use
io.swagger.codegen.CodegenConfig.
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: StandaloneCodegenerator.java From swagger-codegen-tooling with Apache License 2.0 | 6 votes |
protected void prepare() { final List<CodegenConfig> extensions = getExtensions(); final StringBuilder sb = new StringBuilder(); for (final CodegenConfig config : extensions) { if (sb.toString().length() != 0) { sb.append(", "); } sb.append(config.getName()); getLog().info("register config : '" + config.getName() + "' with class : " + config.getClass().getName()); configs.put(config.getName(), config); // do not know // configString = sb.toString(); } }
Example #2
Source File: CodegenConfigurator.java From TypeScript-Microservices with MIT License | 5 votes |
private void handleDynamicProperties(CodegenConfig codegenConfig) { for (CliOption langCliOption : codegenConfig.cliOptions()) { String opt = langCliOption.getOpt(); if (dynamicProperties.containsKey(opt)) { codegenConfig.additionalProperties().put(opt, dynamicProperties.get(opt)); } else if(systemProperties.containsKey(opt)) { codegenConfig.additionalProperties().put(opt, systemProperties.get(opt)); } } }
Example #3
Source File: ConfigHelp.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public void run() { System.out.println(); CodegenConfig config = CodegenConfigLoader.forName(lang); System.out.println("CONFIG OPTIONS"); for (CliOption langCliOption : config.cliOptions()) { System.out.println("\t" + langCliOption.getOpt()); System.out.println("\t " + langCliOption.getOptionHelp().replaceAll("\n", "\n\t ")); System.out.println(); } }
Example #4
Source File: StandaloneCodegenerator.java From swagger-codegen-tooling with Apache License 2.0 | 5 votes |
private CodegenConfig getConfig(final String name) { if (configs.containsKey(name)) { return configs.get(name); } else { try { getLog().info("loading class " + name); final Class<?> customClass = Class.forName(name); getLog().info("loaded " + name); return (CodegenConfig) customClass.newInstance(); } catch (final Exception e) { throw new RuntimeException("can't load config-class for '" + name + "'", e); } } }
Example #5
Source File: StandaloneCodegenerator.java From swagger-codegen-tooling with Apache License 2.0 | 5 votes |
private List<CodegenConfig> getExtensions() { final ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class); final List<CodegenConfig> output = new ArrayList<CodegenConfig>(); final Iterator<CodegenConfig> itr = loader.iterator(); while (itr.hasNext()) { output.add(itr.next()); } return output; }
Example #6
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 #7
Source File: Langs.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void run() { LambdaIterable<String> langs = with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName()); System.out.printf("Available languages: %s%n", langs); }
Example #8
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 #9
Source File: SwaggerContext.java From sundrio with Apache License 2.0 | 4 votes |
public CodegenConfig getConfig() { return config; }
Example #10
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; }