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

PAYARA-3466 Open API 1.1 #3827

Merged
merged 10 commits into from Mar 19, 2019

Conversation

Projects
None yet
4 participants
@jbee
Copy link
Contributor

commented Mar 12, 2019

Summary:

  • Add generics to Extensible hierarchy (added in 1.1)
  • Implemented new methods (mostly explicit type-safe add/remove/contains)
  • Replaced usage of deprecated methods with type-safe replacements added in 1.1
  • Removed methods now implemented as default methods in the API interfaces
  • Added processing of @Parameters (missed both by TCK and us in 1.0)
  • Added processing of @Extensions (missed both by TCK and us in 1.0)
  • Added null check to addX methods (I think 1.1 addec this semantic or 1.0 TCK missed to check)
  • Added copy constructor for Map model types for their "copy getter" (see API javadoc)
  • Extracted a common base type for Extensible Maps (share impl.)
  • Some more specific local fixes for minor deviations from the spec since 1.0 that TCK 1.1 now found
  • Fixed some serialisation issues (present since 1.0)

jbee added some commits Mar 8, 2019

PAYARA-3466 Open API 1.1 implemented new methods, removed builder wit…
…h defaults, removed warnings, extracted common base classes for extensible maps, switched to non-deprecated methods

@jbee jbee added this to the 5.192 milestone Mar 12, 2019

@jbee jbee self-assigned this Mar 12, 2019

@@ -98,4 +129,34 @@ public static Object convertExtensionValue(String value) {
return value;
}

@Override
public String toString() {

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: Added this to ease debugging by providing a helpful toString for the model.

ExampleImpl.merge(example, to.getMediaType(typeName).getExamples(), override);
}
if (!from.example().isEmpty()) {
to.getMediaType(typeName).setExample(from.example());

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: example is a new property in 1.1


@Override
public Scopes addScope(String name, String item) {
this.put(name, item);
this.put(name, item); // this DOES accept null!

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: This seems inconsistent but this add method explicitly allows for null while usually the add methods do not allow for null or should ignore it.

@Override
public SecurityRequirement addScheme(String name, String item) {
this.put(name, Arrays.asList(item));
this.put(name, item == null ? new ArrayList<>() : Arrays.asList(item));

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: null should become empty list

return this;
}

@Override
public SecurityRequirement addScheme(String name, List<String> item) {
this.put(name, item);
this.put(name, item == null ? new ArrayList<>() : item);

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: null should become empty list

return variables;
return variables instanceof ServerVariables || variables == null
? (ServerVariables) variables
: new ServerVariablesImpl(variables);

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: ServerVariables got "half-removed". It is deprecated and should be removed in the future. In some places it already was replaced with a Map<String, SeverVariable> what causes changes here.

public static Boolean mergeProperty(boolean current, boolean offer, boolean override) {
return mergeProperty(Boolean.valueOf(current), Boolean.valueOf(offer), override);
}

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: I added this overloaded variants to avoid boxing/unboxing warnings. The module is almost free of warnings and it would be nice to get there.

try (DataInputStream in = new DataInputStream(stream)) {
// Reading the binary data
in.readFully(buff);
}

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: fixed potential resource leak.

if (element instanceof java.lang.reflect.Parameter) {
visitSchemaParameter(schema, (java.lang.reflect.Parameter) element, context);
}
}

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: extracted the cases into one method each to make this more readable.

String name = extension.name();
if (name != null && !name.isEmpty() && value != null
&& !value.isEmpty()) {
Object parsedValue = ExtensibleImpl.convertExtensionValue(value, extension.parseValue());

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: here we were missing applying conversion via convertExtensionValue.

}
}
}
matchedParam = findOperationParameterFor(parameter, (Method) element, context);

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: extracted the cases to make it more readable. Also the loop in the cases should stop when a match is found. This is simpler done with a return in a separate method.

.removeIf(x -> ModelUtils.getParameterType(x) != In.valueOf(in.name()));
}
if (matchingMethodParameters.isEmpty()) {
return null;

This comment has been minimized.

Copy link
@jbee

jbee Mar 12, 2019

Author Contributor

FYI: This is a fix I added. 1.0 TCK simply had no case that would otherwise fail the next line where we always get the first entry of the list. But some cases do not have a matching parameter.

@jbee

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2019

jenkins test please

@jbee jbee requested review from MattGill98, arjantijms and Pandrex247 Mar 12, 2019

// Get all parameters with the same name
List<java.lang.reflect.Parameter> matchingMethodParameters = Arrays
.asList(annotated.getParameters()).stream()
.filter(x -> name.equals(ModelUtils.getParameterName(x)))

This comment has been minimized.

Copy link
@jbee

jbee Mar 13, 2019

Author Contributor

FYI: swapped the equals because ModelUtils.getParameterName(x) can be null causeing NPE while name is from an annotation and cannot be null.

@MattGill98
Copy link
Member

left a comment

Generally good, just a couple of comments from me. As an aside, I'm glad someone has shared my pain of maintaining masses of model classes! 😆

@jbee

This comment has been minimized.

Copy link
Contributor Author

commented Mar 13, 2019

jenkins test please

* {@link ExtensibleTreeMap#extensions} map to the output object unless the value represents a {@link Reference} in
* which case only the {@link Reference#getRef()} is added.
*/
static class ExtensibleTreeMapSerializer extends JsonSerializer<ExtensibleTreeMap<?,?>> {

This comment has been minimized.

Copy link
@jbee

jbee Mar 18, 2019

Author Contributor

FYI: This fixes two defects in the JSON/YAML serialisation present since 1.0 where properties on Map extending types would be ignored as they are handled by the map serializer. Thereby extensions would not be added and in case of a reference an empty object was rendered instead of the reference.

@jbee

This comment has been minimized.

Copy link
Contributor Author

commented Mar 18, 2019

jenkins test please

@Pandrex247 Pandrex247 merged commit ef8e36d into payara:master Mar 19, 2019

59 checks passed

Payara Quick Build and Test Quick build and test passed!
Details
security/snyk - api/payara-api/pom.xml (payara-ci) No new issues
Details
security/snyk - api/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/admin/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/admingui/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ant-tasks/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/appclient/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/batch/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/common/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/concurrent/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/connectors/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/core/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/deployment/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/distributions/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ejb/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/extras/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/featuresets/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/flashlight/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/grizzly/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ha/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/installer/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/javaee-api/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/jdbc/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/jms/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/load-balancer/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/orb/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/osgi-platforms/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/packager/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/payara-appserver-modules/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/persistence/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/registration/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/resources/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/security/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/tests/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/transaction/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/web/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/webservices/pom.xml (payara-ci) No new issues
Details
security/snyk - copyright/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/admin/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/cluster/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/common/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/core/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/deployment/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/diagnostics/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/distributions/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/flashlight/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/grizzly/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/hk2/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/osgi-platforms/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/packager/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/payara-modules/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/resources-l10n/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/resources/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/security/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/test-utils/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/tests/pom.xml (payara-ci) No new issues
Details
security/snyk - pom.xml (payara-ci) No new issues
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.