It seems that the object name is correctly camelCased for JAVA/Spring, but that the usage in $ref leaves it with the underscores. I read many other notes that suggested that I could force it to always use underscore, but I would hope that they would be consistent out of the box.
Swagger-codegen versionswagger-codegen-cli-3.0.0-20180616.031247-80.jar
Swagger declaration file content or urlopenapi: '3.0.0'
info:
title: Foo API
version: 'v1'
components:
schemas:
error_general:
type: object
description: A general error has been encountered.
required:
- error_code
- error_message
properties:
error_code:
type: integer
description: The code that describes the error.
error_message:
type: string
error_validation:
allOf:
- $ref: '#/components/schemas/error_general'
description: An input validation error has been encountered.
required:
- errors
properties:
errors:
type: integer
paths:
/foo:
put:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/error_general'
required: true
responses:
400:
description: Invalid ID supplied
content: {}
java -jar swagger-codegen-cli-3.0.0-20180616.031247-80.jar generate -l java -i test.yaml -Dmodels -l java
or
$ java -jar swagger-codegen-cli-3.0.0-20180616.031247-80.jar generate -l java -i test.yaml -Dmodels -l spring --library spring-mvc
Steps to reproduceExamine generated classes....
The classes ErrorGeneral.java and ErrorValidation.java are created, but ErrorValidation extends Error_general instead of ErrorGeneral.
`package io.swagger.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.model.Error_general;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
public class ErrorValidation extends Error_general {
@JsonProperty("errors")
private Integer errors = null;
public ErrorValidation errors(Integer errors) {
this.errors = errors;
return this;
}
/**
Get errors
@return errors
**/
@ApiModelProperty(required = true, value = "")
public Integer getErrors() {
return errors;
}
public void setErrors(Integer errors) {
this.errors = errors;
}
@OverRide
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ErrorValidation errorValidation = (ErrorValidation) o;
return Objects.equals(this.errors, errorValidation.errors) &&
super.equals(o);
}
@OverRide
public int hashCode() {
return Objects.hash(errors, super.hashCode());
}
@OverRide
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ErrorValidation {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" errors: ").append(toIndentedString(errors)).append("\n");
sb.append("}");
return sb.toString();
}
/**
`
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4