test_class.declarator: settings
test_class.modifier: private
test_class.original_string: private TypescriptServiceGeneratorConfiguration settings;
test_class.type: TypescriptServiceGeneratorConfiguration
test_class.var_name: settings
test_class.declarator: writer
test_class.modifier: private
test_class.original_string: private IndentedOutputWriter writer;
test_class.type: IndentedOutputWriter
test_class.var_name: writer
test_class.declarator: stream
test_class.modifier: private
test_class.original_string: private ByteArrayOutputStream stream;
test_class.type: ByteArrayOutputStream
test_class.var_name: stream
test_class.declarator: serviceClassParser
test_class.modifier: private
test_class.original_string: private ServiceClassParser serviceClassParser;
test_class.type: ServiceClassParser
test_class.var_name: serviceClassParser
test_class.file: typescript-service-generator-core/src/test/java/com/palantir/code/ts/generator/ServiceEmitterTest.java
test_class.identifier: ServiceEmitterTest
test_case.body: @Test
      public void testEnumDataParameter() {
          ServiceModel model = serviceClassParser.parseServiceClass(EnumClass.class, settings);
          ServiceEmitter serviceEmitter = new ServiceEmitter(model, settings, writer);
          serviceEmitter.emitTypescriptClass();
          writer.close();
          String expectedToContain = "data: `\"${myEnum}\"`";
          assertTrue(new String(stream.toByteArray()).contains(expectedToContain));
      }
test_case.class_method_signature: ServiceEmitterTest.testEnumDataParameter()
test_case.full_signature: @Test public void testEnumDataParameter()
test_case.identifier: testEnumDataParameter
test_case.invocations: parseServiceClass emitTypescriptClass close assertTrue contains toByteArray
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEnumDataParameter()
focal_class.declarator: OBJECT_MAPPER = new ObjectMapper()
focal_class.modifier: private static final
focal_class.original_string: private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
focal_class.type: ObjectMapper
focal_class.var_name: OBJECT_MAPPER
focal_class.declarator: model
focal_class.modifier: private final
focal_class.original_string: private final ServiceModel model;
focal_class.type: ServiceModel
focal_class.var_name: model
focal_class.declarator: settings
focal_class.modifier: private final
focal_class.original_string: private final TypescriptServiceGeneratorConfiguration settings;
focal_class.type: TypescriptServiceGeneratorConfiguration
focal_class.var_name: settings
focal_class.declarator: writer
focal_class.modifier: private final
focal_class.original_string: private final IndentedOutputWriter writer;
focal_class.type: IndentedOutputWriter
focal_class.var_name: writer
focal_class.file: typescript-service-generator-core/src/main/java/com/palantir/code/ts/generator/ServiceEmitter.java
focal_class.identifier: ServiceEmitter
focal_class.class_method_signature: ServiceEmitter.ServiceEmitter(ServiceModel model, TypescriptServiceGeneratorConfiguration settings, IndentedOutputWriter writer)
focal_class.full_signature: public  ServiceEmitter(ServiceModel model, TypescriptServiceGeneratorConfiguration settings, IndentedOutputWriter writer)
focal_class.identifier: ServiceEmitter
focal_class.modifiers: public
focal_class.parameters: (ServiceModel model, TypescriptServiceGeneratorConfiguration settings, IndentedOutputWriter writer)
focal_class.signature:  ServiceEmitter(ServiceModel model, TypescriptServiceGeneratorConfiguration settings, IndentedOutputWriter writer)
focal_class.class_method_signature: ServiceEmitter.emitTypescriptTypes(TypescriptServiceGeneratorConfiguration settings, List<Type> additionalTypesToOutput)
focal_class.full_signature: public void emitTypescriptTypes(TypescriptServiceGeneratorConfiguration settings, List<Type> additionalTypesToOutput)
focal_class.identifier: emitTypescriptTypes
focal_class.modifiers: public
focal_class.parameters: (TypescriptServiceGeneratorConfiguration settings, List<Type> additionalTypesToOutput)
focal_class.return: void
focal_class.signature: void emitTypescriptTypes(TypescriptServiceGeneratorConfiguration settings, List<Type> additionalTypesToOutput)
focal_class.class_method_signature: ServiceEmitter.emitTypescriptClass()
focal_class.full_signature: public void emitTypescriptClass()
focal_class.identifier: emitTypescriptClass
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void emitTypescriptClass()
focal_class.class_method_signature: ServiceEmitter.emitTypescriptInterface()
focal_class.full_signature: public void emitTypescriptInterface()
focal_class.identifier: emitTypescriptInterface
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void emitTypescriptInterface()
focal_class.class_method_signature: ServiceEmitter.getDuplicateEndpointNames()
focal_class.full_signature: private Set<String> getDuplicateEndpointNames()
focal_class.identifier: getDuplicateEndpointNames
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> getDuplicateEndpointNames()
focal_class.class_method_signature: ServiceEmitter.getEndpointPathString(InnerServiceModel model, ServiceEndpointModel endpointModel)
focal_class.full_signature: private String getEndpointPathString(InnerServiceModel model, ServiceEndpointModel endpointModel)
focal_class.identifier: getEndpointPathString
focal_class.modifiers: private
focal_class.parameters: (InnerServiceModel model, ServiceEndpointModel endpointModel)
focal_class.return: String
focal_class.signature: String getEndpointPathString(InnerServiceModel model, ServiceEndpointModel endpointModel)
focal_class.class_method_signature: ServiceEmitter.getEndpointParametersString(ServiceEndpointModel endpointModel)
focal_class.full_signature: private String getEndpointParametersString(ServiceEndpointModel endpointModel)
focal_class.identifier: getEndpointParametersString
focal_class.modifiers: private
focal_class.parameters: (ServiceEndpointModel endpointModel)
focal_class.return: String
focal_class.signature: String getEndpointParametersString(ServiceEndpointModel endpointModel)
focal_class.class_method_signature: ServiceEmitter.filterInputClasses(Set<Class<?>> referencedClasses)
focal_class.full_signature: private Set<Class<?>> filterInputClasses(Set<Class<?>> referencedClasses)
focal_class.identifier: filterInputClasses
focal_class.modifiers: private
focal_class.parameters: (Set<Class<?>> referencedClasses)
focal_class.return: Set<Class<?>>
focal_class.signature: Set<Class<?>> filterInputClasses(Set<Class<?>> referencedClasses)
focal_class.class_method_signature: ServiceEmitter.getReferencedClasses(Set<Type> referencedTypes, TypescriptServiceGeneratorConfiguration settings)
focal_class.full_signature: public static Set<Class<?>> getReferencedClasses(Set<Type> referencedTypes, TypescriptServiceGeneratorConfiguration settings)
focal_class.identifier: getReferencedClasses
focal_class.modifiers: public static
focal_class.parameters: (Set<Type> referencedTypes, TypescriptServiceGeneratorConfiguration settings)
focal_class.return: Set<Class<?>>
focal_class.signature: Set<Class<?>> getReferencedClasses(Set<Type> referencedTypes, TypescriptServiceGeneratorConfiguration settings)
focal_class.class_method_signature: ServiceEmitter.optionalToString(Optional<T> payload)
focal_class.full_signature: private static String optionalToString(Optional<T> payload)
focal_class.identifier: optionalToString
focal_class.modifiers: private static
focal_class.parameters: (Optional<T> payload)
focal_class.return: String
focal_class.signature: String optionalToString(Optional<T> payload)
focal_method.body: public void emitTypescriptClass() {
          Set<String> endpointsToWarnAboutDuplicateNames = Sets.newHashSet();
          if (!this.settings.emitDuplicateJavaMethodNames()) {
              endpointsToWarnAboutDuplicateNames = getDuplicateEndpointNames();
          }
          writer.writeLine("");
          // Adding "Impl" ensures the class name is different from the impl name, which is a compilation requirement.
          writer.writeLine("export class " + model.name() + "Impl" + " implements " + settings.getSettings().addTypeNamePrefix + model.name() + " {");
          writer.increaseIndent();
  
          writer.writeLine("");
          writer.writeLine(String.format("private httpApiBridge: %sHttpApiBridge;", settings.generatedInterfacePrefix()));
          writer.writeLine(String.format("constructor(httpApiBridge: %sHttpApiBridge) {", settings.generatedInterfacePrefix()));
          writer.increaseIndent();
          writer.writeLine("this.httpApiBridge = httpApiBridge;");
          writer.decreaseIndent();
          writer.writeLine("}");
  
          for (InnerServiceModel innerServiceModel : model.innerServiceModels()) {
              if (model.innerServiceModels().size() > 1) {
                  writer.writeLine("");
                  writer.writeLine("// endpoints for service class: " + innerServiceModel.name());
              }
              for (ServiceEndpointModel endpointModel: innerServiceModel.endpointModels()) {
                  if (endpointsToWarnAboutDuplicateNames.contains(endpointModel.endpointName())) {
                      // don't output any duplicates
                      continue;
                  }
                  writer.writeLine("");
                  String line = "public " + endpointModel.endpointName() + "(";
                  line += getEndpointParametersString(endpointModel);
                  line += ") {";
                  writer.writeLine(line);
                  writer.increaseIndent();
                  writer.writeLine(String.format("var httpCallData = <%sHttpEndpointOptions> {", settings.generatedInterfacePrefix()));
                  writer.increaseIndent();
                  writer.writeLine("serviceIdentifier: \"" + Character.toLowerCase(model.name().charAt(0)) + model.name().substring(1) + "\",");
                  writer.writeLine("endpointPath: \"" + getEndpointPathString(innerServiceModel, endpointModel) + "\",");
                  writer.writeLine("endpointName: \"" + endpointModel.endpointName() + "\",");
                  writer.writeLine("method: \"" + endpointModel.endpointMethodType() + "\",");
                  writer.writeLine("requestMediaType: \"" + endpointModel.endpointRequestMediaType() + "\",");
                  writer.writeLine("responseMediaType: \"" + optionalToString(endpointModel.endpointResponseMediaType()) + "\",");
                  List<String> requiredHeaders = Lists.newArrayList();
                  List<String> pathArguments = Lists.newArrayList();
                  List<String> queryArguments = Lists.newArrayList();
                  String dataArgument = null;
                  for (ServiceEndpointParameterModel parameterModel : endpointModel.parameters()) {
                      if (parameterModel.headerParam() != null) {
                          requiredHeaders.add("\"" + parameterModel.headerParam() + "\"");
                      } else if (parameterModel.pathParam() != null) {
                          pathArguments.add(parameterModel.getParameterName());
                      } else if (parameterModel.queryParam() != null) {
                          queryArguments.add(parameterModel.queryParam());
                      } else {
                          if (dataArgument != null) {
                              throw new IllegalStateException("There should only be one data argument per endpoint. Found both" + dataArgument + " and " + parameterModel.getParameterName());
                          }
                          dataArgument = parameterModel.getParameterName();
                          boolean isEnum = false;
                          if (parameterModel.javaType() instanceof Class<?>) {
                              isEnum = ((Class<?>) parameterModel.javaType()).isEnum();
                          }
                          if (endpointModel.endpointRequestMediaType().equals(MediaType.APPLICATION_JSON) && (parameterModel.tsType().toString().equals("string") || isEnum)) {
                              // strings (and enums, the wire format of an enum is a string) have to be wrapped in quotes in order to be valid json
                              dataArgument = "`\"${" + parameterModel.getParameterName() + "}\"`";
                          }
                      }
                  }
                  writer.writeLine("requiredHeaders: [" + Joiner.on(", ").join(requiredHeaders) + "],");
                  writer.writeLine("pathArguments: [" + Joiner.on(", ").join(pathArguments) + "],");
                  writer.writeLine("queryArguments: {");
                  writer.increaseIndent();
                  for (String queryArgument: queryArguments) {
                      writer.writeLine(queryArgument + ": " + queryArgument + ",");
                  }
                  writer.decreaseIndent();
                  writer.writeLine("},");
                  writer.writeLine("data: " + dataArgument);
                  writer.decreaseIndent();
                  writer.writeLine("};");
                  writer.writeLine("return this.httpApiBridge.callEndpoint<" + endpointModel.tsReturnType().toString() + ">(httpCallData);");
                  writer.decreaseIndent();
                  writer.writeLine("}");
              }
          }
          writer.decreaseIndent();
          writer.writeLine("}");
      }
focal_method.class_method_signature: ServiceEmitter.emitTypescriptClass()
focal_method.full_signature: public void emitTypescriptClass()
focal_method.identifier: emitTypescriptClass
focal_method.invocations: newHashSet emitDuplicateJavaMethodNames getDuplicateEndpointNames writeLine writeLine name getSettings name increaseIndent writeLine writeLine format generatedInterfacePrefix writeLine format generatedInterfacePrefix increaseIndent writeLine decreaseIndent writeLine innerServiceModels size innerServiceModels writeLine writeLine name endpointModels contains endpointName writeLine endpointName getEndpointParametersString writeLine increaseIndent writeLine format generatedInterfacePrefix increaseIndent writeLine toLowerCase charAt name substring name writeLine getEndpointPathString writeLine endpointName writeLine endpointMethodType writeLine endpointRequestMediaType writeLine optionalToString endpointResponseMediaType newArrayList newArrayList newArrayList parameters headerParam add headerParam pathParam add getParameterName queryParam add queryParam getParameterName getParameterName javaType isEnum javaType equals endpointRequestMediaType equals toString tsType getParameterName writeLine join on writeLine join on writeLine increaseIndent writeLine decreaseIndent writeLine writeLine decreaseIndent writeLine writeLine toString tsReturnType decreaseIndent writeLine decreaseIndent writeLine
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void emitTypescriptClass()