Skip to content

[REQ] Better collection serialization support #4039

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

Open
ackintosh opened this issue Oct 3, 2019 · 1 comment
Open

[REQ] Better collection serialization support #4039

ackintosh opened this issue Oct 3, 2019 · 1 comment

Comments

@ackintosh
Copy link
Contributor

ackintosh commented Oct 3, 2019

Is your feature request related to a problem? Please describe.

Since OAS 3.0, in order to support common ways of serializing simple parameters, style and explode are defined instead of collectionFormat.

On the other hand, we still using collectionFormat: style and explode parameters are mapped to collectionFormat.

// TDOO revise collectionFormat
String collectionFormat = null;
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
Schema inner = getSchemaItems(arraySchema);
if (arraySchema.getItems() == null) {
arraySchema.setItems(inner);
}
collectionFormat = getCollectionFormat(parameter);
// default to csv:
collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;

protected String getCollectionFormat(Parameter parameter) {
if (Parameter.StyleEnum.FORM.equals(parameter.getStyle())) {
// Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-values
if (Boolean.TRUE.equals(parameter.getExplode())) { // explode is true (default)
return "multi";
} else {
return "csv";
}
} else if (Parameter.StyleEnum.SIMPLE.equals(parameter.getStyle())) {
return "csv";
} else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle())) {
return "pipe";
} else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) {
return "space";
} else {
return null;
}
}

This can not representate serialization format required in OAS3.

Describe the solution you'd like

In order to make available the serialization format, explode and style parameter values should be assigned to mustache templates, and handle the parameters in each generator.

We need to keep collectionFormat until generators support style and explode.

Additional context

Related PR: #3984

@ybelenko
Copy link
Contributor

Can we close this in favor of #4042 ?

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

No branches or pull requests

2 participants