Comments (13)
Looks lik your array doesn't specify the type
of object in it. If made a string
, you'll get a valid spec:
"models": {
"Author": {
"id": "Author",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"age": {
"type": "int"
},
"books": {
"type": "Array",
"items":{
"type":"string"
}
}
}
}
}
Will fix the validation step so you get a proper error.
from swagger-codegen.
OK pushed a fix to do a null check on the item if it's an array. I found three other issues in your model, namely:
- the
DELETE
method must returnvoid
- the
PUT
method must returnvoid
- the
POST
method is returning anArray[Author]
notArray
The entire authors.json
file is here:
{
"apiVersion": "1",
"swaggerVersion": "1.1",
"basePath": "http://localhost/restler3.dev/raw/swagger",
"apis": [
{
"path": "/authors.{format}/{id}",
"description": "API to list, modify Authors of the Restler",
"operations": [
{
"httpMethod": "GET",
"nickname": "authorsid",
"responseClass": "Author",
"parameters": [
{
"name": "id",
"description": "Author ID . ",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"summary": "Get Author for the specified Author ID",
"notes": "Passing a valid author id, will result in getting details (name, email, author id) of the specific Author.",
"errorResponses": [
{
"reason": "one or more of required fields missing",
"code": 417
},
{
"reason": "Author not found",
"code": 404
}
]
}
]
},
{
"path": "/authors.{format}",
"description": "API to list, modify Authors of the Restler",
"operations": [
{
"httpMethod": "POST",
"nickname": "authors",
"responseClass": "Array[Author]",
"parameters": [
{
"name": "request_data",
"description": "",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"summary": "Create new Author",
"notes": "",
"errorResponses": [
{
"reason": "one or more of required fields missing",
"code": 417
}
]
}
]
},
{
"path": "/authors.{format}/{id}",
"description": "API to list, modify Authors of the Restler",
"operations": [
{
"httpMethod": "PUT",
"nickname": "authorsid",
"responseClass": "void",
"parameters": [
{
"name": "id",
"description": "Author ID . ",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "request_data",
"description": "",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"summary": "Update Author information",
"notes": "",
"errorResponses": [
]
}
]
},
{
"path": "/authors.{format}/something/{id}",
"description": "API to list, modify Authors of the Restler",
"operations": [
{
"httpMethod": "DELETE",
"nickname": "authorssomethingid",
"responseClass": "void",
"parameters": [
{
"name": "id",
"description": "Author ID . ",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"summary": "Delete Author by ID",
"notes": "",
"errorResponses": [
]
}
]
}
],
"resourcePath": "/authors",
"models": {
"Author": {
"id": "Author",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"age": {
"type": "int"
},
"books": {
"items":{
"type":"string"
},
"type": "Array"
}
}
}
}
}
Thanks!
from swagger-codegen.
Thanks, I have fixed them all and I'm able to run the tests with zero issues
from swagger-codegen.
sweet!
from swagger-codegen.
Hi, I have a problem with model schema. It is not able to display the type for embedded class. For suppose, In one response body class I have is user defined class and it has List like objects. In swagger model schema it presents it as Array[any]. Is there is way specify the exact type.
from swagger-codegen.
Can you share the class itself that you're trying to represent? What version of codegen? Is it java or scala code?
from swagger-codegen.
I am using code generation for java. This is my pojo class.
@XmlRootElement(name="SubscriptionDetails")
public class SubscriptionDetails implements Serializable{
public static enum PROTOCOL {SMS,EMAIL,FAX};
private UserDetails subscriber;
private List<SubscriptionCriteria> subscriptionCriterias;
private TimingDetails alertTimings;
private Boolean active;
private List<PROTOCOL> protocols = new ArrayList<SubscriptionDetails.PROTOCOL>();
private List<NotificationPreference> notificationPreferences;
/**
* @param alertTypeId the alertTypeId to set
*/
public void setAlertTypeId(Integer alertTypeId) {
this.alertTypeId = alertTypeId;
}
/**
* @return the alertTypeId
*/
public Integer getAlertTypeId() {
return alertTypeId;
}
/**
* @param subscriptionId the subscriptionId to set
*/
public void setSubscriptionId(Integer subscriptionId) {
this.subscriptionId = subscriptionId;
}
/**
* @return the subscriptionId
*/
public Integer getSubscriptionId() {
return subscriptionId;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param protocols the protocols to set
*/
public void setProtocols(List<PROTOCOL> protocols) {
this.protocols = protocols;
}
/**
* @return the protocols
*/
public List<PROTOCOL> getProtocols() {
return protocols;
}
/**
* @param alertTimings the alertTimings to set
*/
public void setAlertTimings(TimingDetails alertTimings) {
this.alertTimings = alertTimings;
}
/**
* @return the alertTimings
*/
public TimingDetails getAlertTimings() {
return alertTimings;
}
/**
* @return the notificationPreferences
*/
public List<NotificationPreference> getNotificationPreferences() {
return notificationPreferences;
}
/**
* @param notificationPreferences the notificationPreferences to set
*/
public void setNotificationPreferences(
List<NotificationPreference> notificationPreferences) {
this.notificationPreferences = notificationPreferences;
}
/**
* @param criteria the criteria to set
*/
public void setCriteria(String criteria) {
this.criteria = criteria;
}
/**
* @return the criteria
*/
public String getCriteria() {
return criteria;
}
/**
* @param emailIds the emailIds to set
*/
public void setEmailIds(String emailIds) {
this.emailIds = emailIds;
}
/**
* @return the emailIds
*/
public String getEmailIds() {
return emailIds;
}
/**
* @param mobileNos the mobileNos to set
*/
public void setMobileNos(String mobileNos) {
this.mobileNos = mobileNos;
}
/**
* @return the mobileNos
*/
public String getMobileNos() {
return mobileNos;
}
/**
* @param alertType the alertType to set
*/
public void setAlertType(String alertType) {
this.alertType = alertType;
}
/**
* @return the alertType
*/
public String getAlertType() {
return alertType;
}
/**
* @param createdDate the createdDate to set
*/
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
/**
* @return the createdDate
*/
public Date getCreatedDate() {
return createdDate;
}
/**
* @param updatedDate the updatedDate to set
*/
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
/**
* @return the updatedDate
*/
public Date getUpdatedDate() {
return updatedDate;
}
/**
* @return the protocolTypes
*/
public String getProtocolTypes() {
return protocolTypes;
}
/**
* @param protocolTypes the protocolTypes to set
*/
public void setProtocolTypes(String protocolTypes) {
this.protocolTypes = protocolTypes;
}
/**
* @param subscriptionCriterias the subscriptionCriterias to set
*/
public void setSubscriptionCriterias(List<SubscriptionCriteria> subscriptionCriterias) {
this.subscriptionCriterias = subscriptionCriterias;
}
/**
* @return the subscriptionCriterias
*/
public List<SubscriptionCriteria> getSubscriptionCriterias() {
return subscriptionCriterias;
}
/**
* @param subscriber the subscriber to set
*/
public void setSubscriber(UserDetails subscriber) {
this.subscriber = subscriber;
}
/**
* @return the subscriber
*/
public UserDetails getSubscriber() {
return subscriber;
}
}
The web service class is
@OverRide
@put
@path("/subscriptions")
@consumes({"application/json","application/xml"})
@produces({"application/json","application/xml"})
@ApiOperation(value = "Updates an existing subscription", notes = "Updates the subscription details")
@ApiErrors(value = { @ApiError(code = 400, reason = "Subscription details are required") })
public Response updateSubscription(@ApiParam(value = "SubscriptionDetails that needs to be fetched", required = true) SubscriptionDetails subscription) throws DataRequiredException{
//Code
}
from swagger-codegen.
This is model schema was generated by swagger ui
SubscriptionDetails
class SubscriptionDetails(alertTypeId: int, criteria: string, updatedDate: Date, emailIds: string, protocols: Array[any], alertType: string, subscriptionId: int, subscriptionCriterias: Array[any], mobileNos: string, active: boolean, alertTimings: TimingDetails, notificationPreferences: Array[any], subscriber: UserDetails, createdDate: Date, protocolTypes: string)
Please note Array[any] notation for list typed property.
from swagger-codegen.
Can you confirm you're using swagger 1.2.4?
from swagger-codegen.
The maven repository for latest swagger-core_2.9.1 is 1.2.3.
This my dependency set
com.wordnik swagger-core_2.9.1 1.2.3 com.wordnik swagger-jaxrs_2.9.1 1.2.3<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.8</version>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.9.1-1</version>
from swagger-codegen.
But 1.2.4 is not available
from swagger-codegen.
Hi, there are a number of models missing from your sample, and not all the class variables are there, so without reproducing all of it, it's impossible to test.
I just ensured 1.2.4 was pushed to maven central, so if you can try that again shortly, or try 1.2.4-SNAPSHOT (in sonatype oss snapshots) I'd like to see if the issue is fixed with some model recursion fixes from that version.
from swagger-codegen.
This is one of missing models. Please remove all the other models from pojo. And consider this only.
@XmlRootElement(name="SubscriptionCriteria")
public class SubscriptionCriteria {
private String paramName;
private String paramValue;
private String paramDisplayValue;
/**
* @param paramName the paramName to set
*/
public void setParamName(String paramName) {
this.paramName = paramName;
}
/**
* @return the paramName
*/
public String getParamName() {
return paramName;
}
/**
* @param paramValue the paramValue to set
*/
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
/**
* @return the paramValue
*/
public String getParamValue() {
return paramValue;
}
/**
* @param paramDisplayValue the paramDisplayValue to set
*/
public void setParamDisplayValue(String paramDisplayValue) {
this.paramDisplayValue = paramDisplayValue;
}
/**
* @return the paramDisplayValue
*/
public String getParamDisplayValue() {
return paramDisplayValue;
}
}
Thanks , 1.2.4-SNAPSHOT is look like not available. I am getting jar not available error in pom. I will wait for 1.2.4 and will see if this issue is fixed. Thank you very much.
from swagger-codegen.
Related Issues (20)
- ### PR Summary
- swagger-codegen python depends on PyYAML>5.1,<6.0 but PyYAML 5.4 is broken HOT 1
- New project
- PHP client SDK response elements are re-written and converted to lower case in all models
- Path parameters aren't propagated to operation level
- [c#] csharp and csharp-dotnet2 needs new codegen HOT 1
- Exception in thread "main" java.lang.RuntimeException: Can't load config class with name apex HOT 1
- Using APIClient (Python) in AWS Lambda function
- swagger-codegen escapes HTML syntax in descriptions when generating HTML, while swagger-ui does not HOT 2
- swagger codegen depends on non compatible apache 2.0 transitive library
- NullPointerException running swagger-codegen-cli for model with nullable integer enum property in schema definition
- Master branch seem broken... CodegenConfiguratorTest.testFromFile:268 expected [1] but found [0]
- In rust code generation trait objects should contain an explicit `dyn` HOT 1
- Recursive types in rust can't compile. HOT 2
- config "enumPropertyNaming" not working as expected
- Swagger-codegen 3.0.54 do not support msf4j server stub
- [typescript-axios] query property renamed to _query
- [TypeScript-Fetch] Invalid interface definition while setting additionalProperties as true
- Invalid anonymous model name with non-ascii title
- [JAVASpring] Incorrect model classnames but only in lists?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-codegen.