-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue: #185
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
User: | ||
allOf: | ||
- $ref: '#/components/schemas/UserBase' | ||
required: | ||
- name | ||
properties: | ||
name: | ||
type: string | ||
|
||
UserBase: | ||
type: object | ||
required: | ||
- id | ||
properties: | ||
id: | ||
type: integer |
63 changes: 63 additions & 0 deletions
63
example/src/test/java/com/github/muehmar/gradle/openapi/issue185/Issue185Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.github.muehmar.gradle.openapi.issue185; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.github.muehmar.gradle.openapi.util.MapperFactory; | ||
import java.util.Collections; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class Issue185Test { | ||
|
||
private static final ObjectMapper MAPPER = MapperFactory.mapper(); | ||
|
||
@Test | ||
void | ||
userDtoBuilder_when_userBaseDtoHasAdditionalNameProperty_then_additionalNamePropertyDiscarded() | ||
throws JsonProcessingException { | ||
final UserBaseDto userBaseDto = | ||
UserBaseDto.userBaseDtoBuilder() | ||
.setId(1234) | ||
.andOptionals() | ||
.addAdditionalProperty("name", "additional-property-name") | ||
.build(); | ||
final UserDto userDto = | ||
UserDto.userDtoBuilder().setUserBaseDto(userBaseDto).setName("name").build(); | ||
|
||
assertEquals(Collections.emptyMap(), userDto.getAdditionalProperties()); | ||
assertEquals("{\"id\":1234,\"name\":\"name\"}", MAPPER.writeValueAsString(userDto)); | ||
} | ||
|
||
@Test | ||
void userDtoBuilder_when_addAdditionalNameProperty_then_additionalNamePropertyDiscarded() | ||
throws JsonProcessingException { | ||
final UserBaseDto userBaseDto = UserBaseDto.userBaseDtoBuilder().setId(1234).build(); | ||
final UserDto userDto = | ||
UserDto.userDtoBuilder() | ||
.setUserBaseDto(userBaseDto) | ||
.setName("name") | ||
.andOptionals() | ||
.addAdditionalProperty("name", "additional-property-name") | ||
.build(); | ||
|
||
assertEquals(Collections.emptyMap(), userDto.getAdditionalProperties()); | ||
assertEquals("{\"id\":1234,\"name\":\"name\"}", MAPPER.writeValueAsString(userDto)); | ||
} | ||
|
||
@Test | ||
void userDtoBuilder_when_addAdditionalIdProperty_then_additionalIdPropertyDiscarded() | ||
throws JsonProcessingException { | ||
final UserBaseDto userBaseDto = UserBaseDto.userBaseDtoBuilder().setId(1234).build(); | ||
final UserDto userDto = | ||
UserDto.userDtoBuilder() | ||
.setUserBaseDto(userBaseDto) | ||
.setName("name") | ||
.andOptionals() | ||
.addAdditionalProperty("id", "additional-property-id") | ||
.build(); | ||
|
||
assertEquals(Collections.emptyMap(), userDto.getAdditionalProperties()); | ||
assertEquals("{\"id\":1234,\"name\":\"name\"}", MAPPER.writeValueAsString(userDto)); | ||
} | ||
} |