-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for multipart and x-www-form-encoded when callmode is t…
…rue (#341)
- Loading branch information
1 parent
e5dbf2c
commit 996f205
Showing
17 changed files
with
1,141 additions
and
36 deletions.
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
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
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
75 changes: 75 additions & 0 deletions
75
...test/resources/openapigenerator/testRestClientApiWithRequestObjectGeneration/api-test.yml
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,75 @@ | ||
--- | ||
openapi: "3.0.0" | ||
info: | ||
version: 1.0.0 | ||
title: Sngular Test Api | ||
license: | ||
name: MIT | ||
servers: | ||
- url: http://localhost:8080/v1 | ||
paths: | ||
/test/form_url_encoded: | ||
summary: test | ||
get: | ||
summary: Test url form encoded | ||
operationId: test_form_url_encoded | ||
tags: | ||
- test | ||
requestBody: | ||
required: true | ||
content: | ||
application/x-www-form-urlencoded: | ||
schema: | ||
$ref: "#/components/schemas/TestInput" | ||
responses: | ||
'200': | ||
description: Test response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/TestResponse" | ||
/test/multipart: | ||
summary: test | ||
get: | ||
summary: Test multipart | ||
operationId: test_multipart | ||
tags: | ||
- test | ||
requestBody: | ||
required: true | ||
content: | ||
multipart/form-data: | ||
schema: | ||
$ref: "#/components/schemas/TestInput" | ||
responses: | ||
'200': | ||
description: Test response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/TestResponse" | ||
|
||
components: | ||
schemas: | ||
TestInput: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
format: int32 | ||
name: | ||
type: string | ||
TestResponse: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
format: int32 | ||
name: | ||
type: string |
111 changes: 111 additions & 0 deletions
111
...ces/openapigenerator/testRestClientApiWithRequestObjectGeneration/assets/ApiErrorDTO.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,111 @@ | ||
package com.sngular.multifileplugin.restclient.model; | ||
|
||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import com.sngular.multifileplugin.restclient.model.exception.ModelClassException; | ||
|
||
public class ApiErrorDTO { | ||
|
||
@JsonProperty(value ="code") | ||
private final Integer code; | ||
@JsonProperty(value ="message") | ||
private final String message; | ||
|
||
private ApiErrorDTO(Integer code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
|
||
validateRequiredAttributes(); | ||
} | ||
|
||
private ApiErrorDTO(ApiErrorDTOBuilder builder) { | ||
this.code = builder.code; | ||
this.message = builder.message; | ||
|
||
validateRequiredAttributes(); | ||
} | ||
|
||
public static ApiErrorDTO.ApiErrorDTOBuilder builder() { | ||
return new ApiErrorDTO.ApiErrorDTOBuilder(); | ||
} | ||
|
||
public static class ApiErrorDTOBuilder { | ||
|
||
private Integer code; | ||
private String message; | ||
|
||
public ApiErrorDTO.ApiErrorDTOBuilder code(Integer code) { | ||
this.code = code; | ||
return this; | ||
} | ||
|
||
public ApiErrorDTO.ApiErrorDTOBuilder message(String message) { | ||
this.message = message; | ||
return this; | ||
} | ||
|
||
public ApiErrorDTO build() { | ||
ApiErrorDTO apiErrorDTO = new ApiErrorDTO(this); | ||
return apiErrorDTO; | ||
} | ||
} | ||
|
||
|
||
@Schema(name = "code", required = true) | ||
public Integer getCode() { | ||
return code; | ||
} | ||
|
||
|
||
@Schema(name = "message", required = true) | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ApiErrorDTO apiErrorDTO = (ApiErrorDTO) o; | ||
return Objects.equals(this.code, apiErrorDTO.code) && Objects.equals(this.message, apiErrorDTO.message); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(code, message); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("ApiErrorDTO{"); | ||
sb.append(" code:").append(code).append(","); | ||
sb.append(" message:").append(message); | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
|
||
|
||
|
||
private void validateRequiredAttributes() { | ||
boolean satisfiedCondition = true; | ||
|
||
if (!Objects.nonNull(this.code)) { | ||
satisfiedCondition = false; | ||
} else if (!Objects.nonNull(this.message)) { | ||
satisfiedCondition = false; | ||
} | ||
|
||
if (!satisfiedCondition) { | ||
throw new ModelClassException("ApiErrorDTO"); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.