All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wordnik.swagger.codegen.languages.StaticHtmlGenerator Maven / Gradle / Ivy

The newest version!
package com.wordnik.swagger.codegen.languages;

import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;

import java.util.*;
import java.io.File;

public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
  protected String invokerPackage = "com.wordnik.client";
  protected String groupId = "com.wordnik";
  protected String artifactId = "swagger-client";
  protected String artifactVersion = "1.0.0";
  protected String sourceFolder = "src/main/scala";

  public CodegenType getTag() {
    return CodegenType.DOCUMENTATION;
  }

  public String getName() {
    return "html";
  }

  public String getHelp() {
    return "Generates a static HTML file.";
  }

  public StaticHtmlGenerator() {
    super();
    outputFolder = "docs";
    templateDir = "htmlDocs";

    defaultIncludes = new HashSet();

    String partner = "our Partner";

    if(System.getProperty("partner") != null)
      partner = System.getProperty("partner");

    additionalProperties.put("partner", partner);
    additionalProperties.put("appName", "Swagger Sample");
    additionalProperties.put("appDescription", "A sample swagger server");
    additionalProperties.put("infoUrl", "https://helloreverb.com");
    additionalProperties.put("infoEmail", "[email protected]");
    additionalProperties.put("licenseInfo", "All rights reserved");
    additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
    additionalProperties.put("invokerPackage", invokerPackage);
    additionalProperties.put("groupId", groupId);
    additionalProperties.put("artifactId", artifactId);
    additionalProperties.put("artifactVersion", artifactVersion);
  
    supportingFiles.add(new SupportingFile("index.mustache", "", "index.html")); 
    reservedWords = new HashSet();

    languageSpecificPrimitives = new HashSet();
    importMapping = new HashMap ();
  }

  @Override
  public String getTypeDeclaration(Property p) {
    if(p instanceof ArrayProperty) {
      ArrayProperty ap = (ArrayProperty) p;
      Property inner = ap.getItems();
      return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
    }
    else if (p instanceof MapProperty) {
      MapProperty mp = (MapProperty) p;
      Property inner = mp.getAdditionalProperties();

      return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
    }
    return super.getTypeDeclaration(p);
  }

  @Override
  public Map postProcessOperations(Map objs) {
    Map operations = (Map) objs.get("operations");
    List operationList = (List) operations.get("operation");
    for(CodegenOperation op: operationList) {
      op.httpMethod = op.httpMethod.toLowerCase();
    }
    return objs;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy