Skip to content

Commit

Permalink
Merge pull request #8 from blue-veery-gmbh/version-1.2.5-fixes
Browse files Browse the repository at this point in the history
Version 1.2.5 fixes
  • Loading branch information
gunner121 authored Mar 27, 2020
2 parents a11d135 + 303eb72 commit f1e2123
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 46 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,34 @@ To add a dependency on spring-rest2ts-generator using Maven, use the following:
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-generator</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-spring</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-spring-data</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<!-- only if spring data is used-->
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-jackson</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-jax-rs</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<!-- only if JAX-RS is used-->
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-angular2json-impl</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<!-- only if angular2json is used-->
</dependency>
```
Expand Down Expand Up @@ -346,7 +346,7 @@ type name, Java model class must be annotated with `JsonApiModelConfig` annotati
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-angular2json-api</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
```
which needs to be included in Java project.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<packaging>pom</packaging>

<name>spring-rest2ts</name>
Expand Down Expand Up @@ -44,7 +44,7 @@
</developers>

<properties>
<spring-rest2ts.version>1.2.4</spring-rest2ts.version>
<spring-rest2ts.version>1.2.5</spring-rest2ts.version>
</properties>


Expand Down
14 changes: 12 additions & 2 deletions spring-rest2ts-angular2json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-angular2json</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>
<packaging>pom</packaging>
<modules>
<module>spring-rest2ts-angular2json-api</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-angular2json</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-angular2json-api</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-angular2json</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-angular2json-impl</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<dependencies>
<dependency>
<groupId>com.blue-veery</groupId>
Expand Down
18 changes: 14 additions & 4 deletions spring-rest2ts-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,34 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-examples</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>



<dependencies>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-generator</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts-jackson</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.blue-veery</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public OrderDTO getOrder(@PathVariable int id) {
}


@RequestMapping(path = "/{id}", method = RequestMethod.PUT, consumes = {"application/json"}, produces = {"application/json"})
@PutMapping(path = "/{id}", consumes = {"application/json"}, produces = {"application/json"})
@ResponseBody
public OrderDTO updateOrder(@PathVariable int id, @RequestBody OrderDTO entity) {
public OrderDTO updateOrder(@PathVariable(name = "id") int orderId, @RequestBody OrderDTO entity) {
return entity;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var path = require('path');
module.exports = {
entry: {
services: "./src/app/sdk/services/services.ts"
services: "./src/ctrls-spring.ts"
},
mode: "development",
output: {
Expand Down
14 changes: 12 additions & 2 deletions spring-rest2ts-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-generator</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected SortedSet<Property> getClassProperties(Class javaClass, ObjectMapper o
if(objectMapper.filter(field)) {
Property property = new Property(objectMapper.getPropertyName(field), currentIndex++, field);
propertyMap.put(property.getName(), property);
objectMapper.setIfIsIgnored(property, field);
}
}
}
Expand All @@ -71,13 +72,15 @@ protected SortedSet<Property> getClassProperties(Class javaClass, ObjectMapper o
final int newIndex = currentIndex++;
Property property = propertyMap.computeIfAbsent(propertyName, (key) -> new Property(key, newIndex));
property.setGetter(method);
objectMapper.setIfIsIgnored(property, method);
}

if(couldBeSetter(method) && objectMapper.filter(method, false)){
String propertyName = objectMapper.getPropertyName(method, false);
final int newIndex = currentIndex++;
Property property = propertyMap.computeIfAbsent(propertyName, (key) -> new Property(key, newIndex));
property.setSetter(method);
objectMapper.setIfIsIgnored(property, method);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.blueveery.springrest2ts.tsmodel.TSComplexElement;
import com.blueveery.springrest2ts.tsmodel.TSField;

import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
Expand All @@ -23,4 +24,6 @@ List<TSField> mapJavaPropertyToField(Property property, TSComplexElement tsCompl
String getPropertyName(Field field);

String getPropertyName(Method method, boolean isGetter);

void setIfIsIgnored(Property property, AnnotatedElement annotatedElement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Property implements Comparable<Property>{
private Field field;
private Method getter;
private Method setter;
private boolean isIgnored;
private Class<?> declaringClass;

public Property(String name, int index) {
Expand Down Expand Up @@ -55,6 +56,14 @@ public void setSetter(Method setter) {
declaringClass = setter.getDeclaringClass();
}

public boolean isIgnored() {
return isIgnored;
}

public void setIgnored(boolean ignored) {
isIgnored = ignored;
}

public boolean isReadOnly() {
return field == null && setter == null;
}
Expand Down
14 changes: 12 additions & 2 deletions spring-rest2ts-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-jackson</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ public List<TSField> mapJavaPropertyToField(Property property, TSComplexElement
ImplementationGenerator implementationGenerator,
NullableTypesStrategy nullableTypesStrategy) {
List<TSField> tsFieldList = new ArrayList<>();

if (property.isIgnored()) {
return tsFieldList;
}

Type fieldJavaGetterType = property.getGetterType();
if (fieldJavaGetterType != null) {
fieldJavaGetterType = applyJsonValue(fieldJavaGetterType);
Expand Down Expand Up @@ -262,6 +267,14 @@ public String getPropertyName(Method method, boolean isGetter) {
return name;
}

@Override
public void setIfIsIgnored(Property property, AnnotatedElement annotatedElement) {
JsonIgnore jsonIgnore = annotatedElement.getDeclaredAnnotation(JsonIgnore.class);
if (jsonIgnore != null && jsonIgnore.value()) {
property.setIgnored(true);
}
}

private String cutPrefix(String methodName, String prefix) {
if (methodName.startsWith(prefix)) {
return Introspector.decapitalize(methodName.replaceFirst(prefix, ""));
Expand Down Expand Up @@ -423,9 +436,6 @@ private boolean commonFilter(AccessibleObject member) {
return true;
}

if (isJsonIgnoreActive(member)){
return true;
}
return false;
}

Expand All @@ -438,14 +448,6 @@ private boolean containsIgnoreTypeAnnotation(Class<?> type) {
return jsonIgnoreType != null && jsonIgnoreType.value();
}

private boolean isJsonIgnoreActive(AccessibleObject member) {
JsonIgnore jsonIgnore = member.getDeclaredAnnotation(JsonIgnore.class);
if (jsonIgnore != null && jsonIgnore.value()) {
return true;
}
return false;
}

private boolean isDefaultVisibility(JsonAutoDetect.Visibility visibility) {
return visibility.equals(JsonAutoDetect.Visibility.DEFAULT);
}
Expand Down
14 changes: 12 additions & 2 deletions spring-rest2ts-jax-rs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-jax-rs</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>

<dependencies>
<dependency>
Expand Down
14 changes: 12 additions & 2 deletions spring-rest2ts-spring-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
<parent>
<groupId>com.blue-veery</groupId>
<artifactId>spring-rest2ts</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</parent>

<artifactId>spring-rest2ts-spring-data</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<description>
Typescript data model and services from rest generator for java spring. It supports generation for Angular and React
</description>
<url>https://github.com/blue-veery-gmbh/spring-rest-2-ts</url>

<organization>
<url>https://github.com/blue-veery-gmbh</url>
<name>blue veery GmbH</name>
</organization>
<inceptionYear>2019</inceptionYear>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public String generateImplementation(TSParameter tsParameter, String pathParamsL

String forOfTemplate = "for(const %s of %s) {\n%s\n}";
StringBuilder code = new StringBuilder();
code.append(String.format(arrayAssignment, queryParamsList, "number", tsParameter.getName() + ".pageNumber+''"));
code.append(String.format(arrayAssignment, queryParamsList, "page", tsParameter.getName() + ".pageNumber+''"));
code.append(String.format(arrayAssignment, queryParamsList, "size", tsParameter.getName() + ".pageSize+''"));

String sortField = tsParameter.getName() + ".sort.sortOrders";
Expand Down
Loading

0 comments on commit f1e2123

Please sign in to comment.