Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeScript DTO generator #15078

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/che-core-typescript-dto-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<goal>test</goal>
</goals>
<configuration>
<forkCount>0</forkCount>
<systemPropertyVariables>
<buildDirectory>${project.build.directory}</buildDirectory>
</systemPropertyVariables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ describe("DTO serialization tests", () => {
expect(customDto.customMap["bar"].name).to.eql("foo");
});

it("check Serializable type", () => {
const customDto: che.plugin.typescript.MyDtoWithSerializable = {

};
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
package org.eclipse.che.plugin.typescript.dto;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -139,6 +140,8 @@ public static String convertType(Type type) {
return "number";
} else if (Boolean.class.equals(type) || Boolean.TYPE.equals(type)) {
return "boolean";
} else if (Serializable.class.equals(type)) {
return "string | number | boolean";
}

return type.getTypeName();
Expand Down Expand Up @@ -210,6 +213,8 @@ public static String convertTypeForDTS(Type containerType, Type type) {
return "number";
} else if (Boolean.class.equals(type) || Boolean.TYPE.equals(type)) {
return "boolean";
} else if (Serializable.class.equals(type)) {
return "string | number | boolean";
}

String declarationPackage = convertToDTSPackageName((Class) containerType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.typescript.dto;

import java.io.Serializable;
import java.util.Map;
import org.eclipse.che.dto.shared.DTO;

@DTO
public interface MyDtoWithSerializableDTO {
Map<String, Serializable> getPreferences();

void setPreferences(Map<String, Serializable> preferences);
}
2 changes: 2 additions & 0 deletions typescript-dto/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
set -e
set -u

rm -f ./index.d.ts

docker run -i --rm -v "$HOME/.m2:/root/.m2" \
-v "$(pwd)/dto-pom.xml:/usr/src/mymaven/pom.xml" \
-w /usr/src/mymaven maven:3.3-jdk-8 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Map;
import org.eclipse.che.api.core.factory.FactoryParameter;
import org.eclipse.che.api.core.model.workspace.config.Command;
import org.eclipse.che.api.workspace.shared.dto.devfile.PreviewUrlDto;
import org.eclipse.che.dto.shared.DTO;

/** @author Alexander Garagatyi */
Expand Down Expand Up @@ -54,4 +55,11 @@ public interface CommandDto extends Command {
void setAttributes(Map<String, String> attributes);

CommandDto withAttributes(Map<String, String> attributes);

@Override
PreviewUrlDto getPreviewUrl();

void setPreviewUrl(PreviewUrlDto previewUrl);

CommandDto withPreviewUrl(PreviewUrlDto previewUrl);
}