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

[Java/Spring] all-of and one-of Improvements and Fixes #12075

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
da4712c
Add config to reproduce the issue
cachescrubber Apr 5, 2022
af9d7b3
Add test case to reproduce issue.
cachescrubber Apr 5, 2022
628de7d
Debug Session: identify critical codep path
cachescrubber Apr 6, 2022
3a26775
Works exactly as needed for oneOf/allOf in Java/Spring
cachescrubber Apr 6, 2022
ca6ee6e
Add allVars to omit list in OneOfImplementorAdditionalData
cachescrubber Apr 7, 2022
a4d79b3
SpringCodegen: Support parentVars in order to support fluent setter w…
cachescrubber Apr 7, 2022
34fe8af
Generate Samples
cachescrubber Apr 7, 2022
751455f
Add imports for inherited Properties
cachescrubber Apr 7, 2022
3fd8712
Add JavaDoc
cachescrubber Apr 7, 2022
3bb412a
Polishing
cachescrubber Apr 7, 2022
e224d61
add a link to zozo tech blog post
wing328 Apr 5, 2022
e7075d2
[java] Add jersey3 support to the Java client (#12046)
wing328 Apr 5, 2022
10e1a60
more checks in validateJsonObject (#12041)
wing328 Apr 5, 2022
4827d74
add response headers to api exception (#12042)
wing328 Apr 5, 2022
91bfb2f
[Ruby] Fix incorrectly capitalized identifier in apis template (#12045)
harmony7 Apr 5, 2022
726dcc0
update jackson databind to newer version (#12053)
wing328 Apr 5, 2022
7ebd09e
[PowerShell] add more tests to powershell client (#12057)
wing328 Apr 6, 2022
0924cab
comment out error message debug (#12056)
wing328 Apr 6, 2022
3f197e4
Reduce casting for operations processing (#12002)
borsch Apr 6, 2022
4e2995d
[typescript] Support esbuild, second attempt (#11465)
bodograumann Apr 6, 2022
13dbbc7
Fix the null pointer exception when generating examples for schemas i…
spacether Apr 7, 2022
6f3bf90
surefire plugin 3.0.0-M6 (#12076)
sullis Apr 7, 2022
852f8c3
[python-experimental] adds missing init files in endpoint modules (#1…
spacether Apr 7, 2022
1ed0ba7
testng 7.5 (#11380)
sullis Apr 7, 2022
1cee11e
Eliminates handlebars helper warnings (#12078)
spacether Apr 7, 2022
324d000
Adds postProcess method to python-experimental (#12079)
spacether Apr 7, 2022
231364f
[PowerShell] better enum model support (#12082)
wing328 Apr 8, 2022
9cf3029
docs: updated supported angular version (#12072)
takkiraz Apr 8, 2022
a5b7900
Fixed typo in readme which caused the project link to be broken (#12083)
lukacsaronzs Apr 8, 2022
1643c55
Bump actions/setup-java from 2 to 3 (#12087)
dependabot[bot] Apr 9, 2022
a1c4e37
Configure apiNameSuffix via plugins (#12062)
borsch Apr 9, 2022
940d240
[dart-dio] Adds support for enumUnknownDefaultCase to dart builtvalue…
josh-burton Apr 9, 2022
23995be
[php-slim4] Add Mock Server (#12044)
ybelenko Apr 9, 2022
5f4eccd
Adds 'params_encoder' config option for Ruby clients using Faraday (#…
dkliban Apr 9, 2022
eb4c696
Remove restrictions for additional property types (#11802)
impl Apr 9, 2022
bd9f1b6
Specify source encoding in java/kotlin sample poms templates (#12088)
wing328 Apr 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ components:
- $ref: '#/components/schemas/Entity'
FooRef:
type: object
discriminator:
propertyName: '@type'
properties:
foorefPropA:
type: string
allOf:
- $ref: '#/components/schemas/EntityRef'
BarRef:
type: object
allOf:
- $ref: '#/components/schemas/EntityRef'
Bar_Create:
type: object
properties:
Expand All @@ -149,6 +151,11 @@ components:
$ref: '#/components/schemas/FooRefOrValue'
allOf:
- $ref: '#/components/schemas/Entity'
BarRefOrValue:
type: object
oneOf:
- $ref: "#/components/schemas/Bar"
- $ref: "#/components/schemas/BarRef"

requestBodies:
Foo:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ src/main/java/org/openapitools/configuration/HomeController.java
src/main/java/org/openapitools/model/Addressable.java
src/main/java/org/openapitools/model/Bar.java
src/main/java/org/openapitools/model/BarCreate.java
src/main/java/org/openapitools/model/BarRef.java
src/main/java/org/openapitools/model/BarRefOrValue.java
src/main/java/org/openapitools/model/Entity.java
src/main/java/org/openapitools/model/EntityRef.java
src/main/java/org/openapitools/model/Extensible.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Bar extends Entity {
public class Bar extends Entity implements BarRefOrValue {

@JsonProperty("id")
private String id;
Expand All @@ -39,6 +39,18 @@ public class Bar extends Entity {
@JsonProperty("foo")
private FooRefOrValue foo;

@JsonProperty("href")
private String href;

@JsonProperty("@schemaLocation")
private String atSchemaLocation;

@JsonProperty("@baseType")
private String atBaseType;

@JsonProperty("@type")
private String atType;

public Bar id(String id) {
this.id = id;
return this;
Expand Down Expand Up @@ -115,6 +127,82 @@ public void setFoo(FooRefOrValue foo) {
this.foo = foo;
}

public Bar href(String href) {
this.href = href;
return this;
}

/**
* Hyperlink reference
* @return href
*/

@Schema(name = "href", description = "Hyperlink reference", required = false)
public String getHref() {
return href;
}

public void setHref(String href) {
this.href = href;
}

public Bar atSchemaLocation(String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
return this;
}

/**
* A URI to a JSON-Schema file that defines additional attributes and relationships
* @return atSchemaLocation
*/

@Schema(name = "@schemaLocation", description = "A URI to a JSON-Schema file that defines additional attributes and relationships", required = false)
public String getAtSchemaLocation() {
return atSchemaLocation;
}

public void setAtSchemaLocation(String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
}

public Bar atBaseType(String atBaseType) {
this.atBaseType = atBaseType;
return this;
}

/**
* When sub-classing, this defines the super-class
* @return atBaseType
*/

@Schema(name = "@baseType", description = "When sub-classing, this defines the super-class", required = false)
public String getAtBaseType() {
return atBaseType;
}

public void setAtBaseType(String atBaseType) {
this.atBaseType = atBaseType;
}

public Bar atType(String atType) {
this.atType = atType;
return this;
}

/**
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull
@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", required = true)
public String getAtType() {
return atType;
}

public void setAtType(String atType) {
this.atType = atType;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -128,12 +216,16 @@ public boolean equals(Object o) {
Objects.equals(this.barPropA, bar.barPropA) &&
Objects.equals(this.fooPropB, bar.fooPropB) &&
Objects.equals(this.foo, bar.foo) &&
Objects.equals(this.href, bar.href) &&
Objects.equals(this.atSchemaLocation, bar.atSchemaLocation) &&
Objects.equals(this.atBaseType, bar.atBaseType) &&
Objects.equals(this.atType, bar.atType) &&
super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(id, barPropA, fooPropB, foo, super.hashCode());
return Objects.hash(id, barPropA, fooPropB, foo, href, atSchemaLocation, atBaseType, atType, super.hashCode());
}

@Override
Expand All @@ -145,6 +237,10 @@ public String toString() {
sb.append(" barPropA: ").append(toIndentedString(barPropA)).append("\n");
sb.append(" fooPropB: ").append(toIndentedString(fooPropB)).append("\n");
sb.append(" foo: ").append(toIndentedString(foo)).append("\n");
sb.append(" href: ").append(toIndentedString(href)).append("\n");
sb.append(" atSchemaLocation: ").append(toIndentedString(atSchemaLocation)).append("\n");
sb.append(" atBaseType: ").append(toIndentedString(atBaseType)).append("\n");
sb.append(" atType: ").append(toIndentedString(atType)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package org.openapitools.model;

import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.openapitools.model.EntityRef;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;


import java.util.*;
import javax.annotation.Generated;

/**
* BarRef
*/


@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class BarRef extends EntityRef implements BarRefOrValue {

@JsonProperty("href")
private String href;

@JsonProperty("@schemaLocation")
private String atSchemaLocation;

@JsonProperty("@baseType")
private String atBaseType;

@JsonProperty("@type")
private String atType;
Copy link
Contributor Author

@cachescrubber cachescrubber Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This properties are pulled in from EntityRef (and Entity) (caused by org.openapitools.codegen.utils.OneOfImplementorAdditionalData#addFromInterfaceModel) and should not be present here.


public BarRef href(String href) {
this.href = href;
return this;
}

/**
* Hyperlink reference
* @return href
*/

@Schema(name = "href", description = "Hyperlink reference", required = false)
public String getHref() {
return href;
}

public void setHref(String href) {
this.href = href;
}

public BarRef atSchemaLocation(String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
return this;
}

/**
* A URI to a JSON-Schema file that defines additional attributes and relationships
* @return atSchemaLocation
*/

@Schema(name = "@schemaLocation", description = "A URI to a JSON-Schema file that defines additional attributes and relationships", required = false)
public String getAtSchemaLocation() {
return atSchemaLocation;
}

public void setAtSchemaLocation(String atSchemaLocation) {
this.atSchemaLocation = atSchemaLocation;
}

public BarRef atBaseType(String atBaseType) {
this.atBaseType = atBaseType;
return this;
}

/**
* When sub-classing, this defines the super-class
* @return atBaseType
*/

@Schema(name = "@baseType", description = "When sub-classing, this defines the super-class", required = false)
public String getAtBaseType() {
return atBaseType;
}

public void setAtBaseType(String atBaseType) {
this.atBaseType = atBaseType;
}

public BarRef atType(String atType) {
this.atType = atType;
return this;
}

/**
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull
@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", required = true)
public String getAtType() {
return atType;
}

public void setAtType(String atType) {
this.atType = atType;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}

@Override
public int hashCode() {
return Objects.hash(href, atSchemaLocation, atBaseType, atTypesuper.hashCode());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Bug caused by org.openapitools.codegen.utils.OneOfImplementorAdditionalData#addToImplementor

}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BarRef {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" href: ").append(toIndentedString(href)).append("\n");
sb.append(" atSchemaLocation: ").append(toIndentedString(atSchemaLocation)).append("\n");
sb.append(" atBaseType: ").append(toIndentedString(atBaseType)).append("\n");
sb.append(" atType: ").append(toIndentedString(atType)).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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.openapitools.model;

import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.openapitools.model.Bar;
import org.openapitools.model.BarRef;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;


import java.util.*;
import javax.annotation.Generated;


@JsonIgnoreProperties(
value = "@type", // ignore manually set @type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the @type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Bar.class, name = "Bar"),
@JsonSubTypes.Type(value = BarRef.class, name = "BarRef")
})

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public interface BarRefOrValue {
public String getAtType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.openapitools.model.Addressable;
import org.openapitools.model.BarRef;
import org.openapitools.model.Extensible;
import org.openapitools.model.FooRef;
import org.openapitools.jackson.nullable.JsonNullable;
Expand All @@ -31,6 +32,7 @@
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = BarRef.class, name = "BarRef"),
@JsonSubTypes.Type(value = FooRef.class, name = "FooRef")
})

Expand Down
Loading