Skip to content

Commit

Permalink
parent change
Browse files Browse the repository at this point in the history
  • Loading branch information
oplekal committed Jan 8, 2025
1 parent 96561ff commit 83ab71b
Show file tree
Hide file tree
Showing 9 changed files with 931 additions and 1,110 deletions.
1,824 changes: 912 additions & 912 deletions eperusteet/eperusteet-service/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package fi.vm.sade.eperusteet.config;

import com.fasterxml.jackson.databind.type.SimpleType;
import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.Schema;
import org.springdoc.core.customizers.ParameterCustomizer;
import org.springdoc.core.customizers.PropertyCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -31,7 +34,7 @@ public PropertyCustomizer enumPropertyCustomizer() {
return (schema, type) -> {
Type javaType = type.getType();
if (javaType instanceof SimpleType && ((SimpleType) javaType).isEnumType()) {
Class<?> enumClass = ((SimpleType)javaType).getRawClass();
Class<?> enumClass = ((SimpleType) javaType).getRawClass();
schema.setEnum(Arrays.stream(enumClass.getEnumConstants())
.map(enumConstant -> ((Enum<?>) enumConstant).name())
.collect(Collectors.toList()));
Expand All @@ -40,6 +43,19 @@ public PropertyCustomizer enumPropertyCustomizer() {
};
}

@Bean
public ParameterCustomizer enumParameterCustomizer() {
return (parameter, methodParameter) -> {
Class<?> paramType = methodParameter.getParameterType();
if (paramType.isEnum()) {
parameter.getSchema().setEnum(Arrays.stream(paramType.getEnumConstants())
.map(enumConstant -> ((Enum<?>) enumConstant).name()) // Ensures uppercase
.collect(Collectors.toList()));
}
return parameter;
};
}

@Bean
public GroupedOpenApi externalOpenApi() {
return GroupedOpenApi.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,9 @@ public boolean equals(Object x, Object y) throws HibernateException {
return Objects.equals(x, y);
}

// @Override
// public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
// String str = rs.getString(names[0]);
// if (str != null) {
// try {
// JsonNode node = mapper.readTree(str);
// return node;
// } catch (IOException e) {
// throw new BusinessRuleViolationException("datan-luku-epaonnistui");
// }
// }
// return JsonNodeFactory.instance.objectNode();
// }

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
if (value != null) {
// String jsonStr = gson.toJson(value);
try {
String s = mapper.writeValueAsString(value);
st.setObject(index, s, Types.OTHER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Page<OsaamismerkkiDto> findOsaamismerkitBy(@Parameter(hidden = true) Osaa
@Parameters({
@Parameter(name = "nimi", schema = @Schema(implementation = String.class), in = ParameterIn.QUERY),
@Parameter(name = "kategoria", schema = @Schema(implementation = Long.class), in = ParameterIn.QUERY),
@Parameter(name = "koodit", schema = @Schema(implementation = Long.class), in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "number"))),
@Parameter(name = "koodit", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "number"))),
@Parameter(name = "poistunut", schema = @Schema(implementation = Boolean.class), in = ParameterIn.QUERY),
@Parameter(name = "kieli", schema = @Schema(implementation = String.class), in = ParameterIn.QUERY)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ public void getJulkaisuLiite(
@PathVariable("perusteId") Long perusteId,
@PathVariable("fileName") String fileName,
@RequestHeader(value = "If-None-Match", required = false) String etag,
String topLevelMediaType,
//HttpServletRequest request,
HttpServletResponse response
) throws IOException {
UUID id = UUID.fromString(FilenameUtils.removeExtension(fileName));
Expand Down
178 changes: 0 additions & 178 deletions eperusteet/pom.xml

This file was deleted.

2 changes: 1 addition & 1 deletion generated/eperusteet.spec.json

Large diffs are not rendered by default.

0 comments on commit 83ab71b

Please sign in to comment.