Код: Выделить всё
openapi: 3.0.1
info:
version: "1.1"
title: xml test
description: some xml test
servers:
- url: 'http://localhost/:8080'
paths:
'/test':
put:
operationId: testMethodNaming
requestBody:
content:
'application/xml':
schema:
$ref: '#/components/schemas/MyRequest'
responses:
'200':
description: 'OK'
components:
schemas:
MyRequest:
type: object
properties:
name:
type: string
xml:
attribute: true
Код: Выделить всё
/**
* MyRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-03-12T15:32:37.070386+01:00[Europe/Berlin]")
public class MyRequest {
@JsonProperty("name")
private String name;
public MyRequest name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
*/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MyRequest myRequest = (MyRequest) o;
return Objects.equals(this.name, myRequest.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MyRequest {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
По какой-то причине я не могу запустить сгенерированный код прямо сейчас, но, похоже, если бы я отправил в конечную точку, он не сможет проанализировать его с помощью этой модели.
Может быть, я пропустил какой-то параметр конфигурации или что-то еще, чтобы он генерировал правильные аннотации?
Посмотрев исходный код openapi, нужное есть аннотации
[*]Шаблон заголовка класса
[*]Шаблон модели (строка 24)
Подробнее здесь: https://stackoverflow.com/questions/551 ... nnotations