Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto generated code generated with a syntax error #34

Open
xam33r opened this issue Nov 29, 2023 · 12 comments
Open

Auto generated code generated with a syntax error #34

xam33r opened this issue Nov 29, 2023 · 12 comments

Comments

@xam33r
Copy link

xam33r commented Nov 29, 2023

Using wp-openapi I turned my basic version of wordpress website to a webapi and used it's description to generate swagger code for java, and that code is generated with a syntax error like this below.
public static final String JSON_PROPERTY_CONTENT = "content";
private WpTemplateContent content = ;

public static final String JSON_PROPERTY_TITLE = "title";
private WpTemplateTitle title = ;

can you please help?

@moon0326
Copy link
Owner

moon0326 commented Nov 29, 2023

@xam33r

Could you please include a bit more details? It would be nice if I could reproduce it.

A sample file with reproducible steps would be the best.

@xam33r
Copy link
Author

xam33r commented Nov 30, 2023

For example, given below is WpTemplateTitle generated class and in another generated class this is how it is being declared

private WpTemplateTitle title = ;

whereas it should be private WpTemplateTitle title ;

` import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;

@JsonPropertyOrder({
WpTemplateTitle.JSON_PROPERTY_RAW,
WpTemplateTitle.JSON_PROPERTY_RENDERED
})
@JsonTypeName("wp_template_title")
@lombok.Data
@SuppressWarnings({"all", "PMD", "CPD-START"})
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-29T10:09:12.020999500+05:00[Asia/Karachi]")
public class WpTemplateTitle {
public static final String JSON_PROPERTY_RAW = "raw";
private String raw;

public static final String JSON_PROPERTY_RENDERED = "rendered";
private String rendered;

public WpTemplateTitle() {
}

public WpTemplateTitle raw(String raw) {
this.raw = raw;
return this;
}

@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_RAW)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getRaw() {
return raw;
}

@JsonProperty(JSON_PROPERTY_RAW)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setRaw(String raw) {
this.raw = raw;
}

public WpTemplateTitle rendered(String rendered) {
this.rendered = rendered;
return this;
}

@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_RENDERED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getRendered() {
return rendered;
}

@JsonProperty(JSON_PROPERTY_RENDERED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setRendered(String rendered) {
this.rendered = rendered;
}

@OverRide
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
WpTemplateTitle wpTemplateTitle = (WpTemplateTitle) o;
return Objects.equals(this.raw, wpTemplateTitle.raw) &&
Objects.equals(this.rendered, wpTemplateTitle.rendered);
}

@OverRide
public int hashCode() {
return Objects.hash(raw, rendered);
}

@OverRide
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class WpTemplateTitle {\n");
sb.append(" raw: ").append(toIndentedString(raw)).append("\n");
sb.append(" rendered: ").append(toIndentedString(rendered)).append("\n");
sb.append("}");
return sb.toString();
}

private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

`

@moon0326
Copy link
Owner

moon0326 commented Dec 8, 2023

For example, given below is WpTemplateTitle generated class and in another generated class this is how it is being declared

private WpTemplateTitle title = ;

whereas it should be private WpTemplateTitle title ;

` import java.util.Objects; import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName;

@JsonPropertyOrder({ WpTemplateTitle.JSON_PROPERTY_RAW, WpTemplateTitle.JSON_PROPERTY_RENDERED }) @JsonTypeName("wp_template_title") @lombok.Data @SuppressWarnings({"all", "PMD", "CPD-START"}) @edu.umd.cs.findbugs.annotations.SuppressFBWarnings @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-29T10:09:12.020999500+05:00[Asia/Karachi]") public class WpTemplateTitle { public static final String JSON_PROPERTY_RAW = "raw"; private String raw;

public static final String JSON_PROPERTY_RENDERED = "rendered"; private String rendered;

public WpTemplateTitle() { }

public WpTemplateTitle raw(String raw) { this.raw = raw; return this; }

@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_RAW) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getRaw() { return raw; }

@JsonProperty(JSON_PROPERTY_RAW) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRaw(String raw) { this.raw = raw; }

public WpTemplateTitle rendered(String rendered) { this.rendered = rendered; return this; }

@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_RENDERED) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getRendered() { return rendered; }

@JsonProperty(JSON_PROPERTY_RENDERED) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRendered(String rendered) { this.rendered = rendered; }

@OverRide public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } WpTemplateTitle wpTemplateTitle = (WpTemplateTitle) o; return Objects.equals(this.raw, wpTemplateTitle.raw) && Objects.equals(this.rendered, wpTemplateTitle.rendered); }

@OverRide public int hashCode() { return Objects.hash(raw, rendered); }

@OverRide public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class WpTemplateTitle {\n"); sb.append(" raw: ").append(toIndentedString(raw)).append("\n"); sb.append(" rendered: ").append(toIndentedString(rendered)).append("\n"); sb.append("}"); return sb.toString(); }

private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); }

}

`

Sorry for the delay. I see what you mean. You've converted your site to Swagger JSON and used JSON to JAVA converter. Unfortunately, I can't help as I'm not familiar with how java converter works. What are you using exactly?

@xam33r
Copy link
Author

xam33r commented Dec 8, 2023

I am using Swagger-codegen utility to generate java code

@dpalic
Copy link

dpalic commented Dec 23, 2023

any update on this issue? facing the same problem with swagger codegen

@moon0326
Copy link
Owner

Sorry for the update

It seems like Swagger-codegen doesn't support OpenAPI 3.1 yet.

See: swagger-api/swagger-codegen#12210

@xam33r
Copy link
Author

xam33r commented Dec 24, 2023 via email

@moon0326
Copy link
Owner

@xam33r Unfortunately, I don't think there is a workaround at the moment. This plugin can't support OpenAPI 3.0 since WordPress schema uses the latest JSON Schema, which is what OpenAPI 3.1 uses. I would closely watch
swagger-api/swagger-codegen#12210 and wait for them to upgrade.

@xam33r
Copy link
Author

xam33r commented Dec 25, 2023 via email

@dpalic
Copy link

dpalic commented Dec 26, 2023

@xam33r Unfortunately, I don't think there is a workaround at the moment. This plugin can't support OpenAPI 3.0 since WordPress schema uses the latest JSON Schema, which is what OpenAPI 3.1 uses. I would closely watch swagger-api/swagger-codegen#12210 and wait for them to upgrade.

the thing is that swagger is supporting 3.1 already. Take a look into my post there with the details. swagger integrated it already a year ago

@xam33r
Copy link
Author

xam33r commented Dec 26, 2023 via email

@moon0326
Copy link
Owner

moon0326 commented Dec 26, 2023

Then why it's causing problems with my code? can you please have a look and help?

On Tue, 26 Dec 2023 at 15:12, Darko @.> wrote: @xam33r https://github.com/xam33r Unfortunately, I don't think there is a workaround at the moment. This plugin can't support OpenAPI 3.0 since WordPress schema uses the latest JSON Schema, which is what OpenAPI 3.1 uses. I would closely watch swagger-api/swagger-codegen#12210 <swagger-api/swagger-codegen#12210> and wait for them to upgrade. the thing is that swagger is supporting 3.1 already. Take a look into my post there with the details. swagger integrated it already a year ago — Reply to this email directly, view it on GitHub <#34 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE57G3FQLMZ4WWNZZHCQLADYLKPIPAVCNFSM6AAAAAA763H43GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRZGQZTCNJVGA . You are receiving this because you were mentioned.Message ID: @.>
-- -- Regards, Zameer Faiz Sr. Java Developer Contact +92302-5477923 @.***> LinkedIn Profile https://pk.linkedin.com/in/zameerfaiz This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee you should not disclose, disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this by mistake, and delete this e-mail from your system.

@xam33r Unfortunately, I don't think there is a workaround at the moment. This plugin can't support OpenAPI 3.0 since WordPress schema uses the latest JSON Schema, which is what OpenAPI 3.1 uses. I would closely watch swagger-api/swagger-codegen#12210 and wait for them to upgrade.

the thing is that swagger is supporting 3.1 already. Take a look into my post there with the details. swagger integrated it already a year ago

Swagger and Swagger-codegen are two different projects AFAIK. Just because Swagger announced and has a tool for support 3.1, it does not mean other tools are ready for 3.1.

This was one of the reasons why I used Elements viewer instead of the official Swagger viewer. At the time of writing this plugin, even the official Swagger viewer did not support OpenAPI 3.1 :)

There isn't even a stable version of Swagger-editor that supports OpenAPI 3.1 yet. Only 5.x.x alpha versions support 3.1 as far as I remember.

Update 1: I've looked at the link you provided in the issue (https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1). It seems like 3.1 should be supported by now according to the check marks on the page 🤔 I'll wait someone to reply to your comment and see where it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants