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

"examples" field does not comply with OpenAPI 3.0 Specification #8

Open
ckho-wkcda opened this issue Jun 2, 2021 · 0 comments
Open

Comments

@ckho-wkcda
Copy link

According to OpenAPI 3.0 Specification,
the field "examples" should be a map.

Example:

examples: 
  foo:
    summary: A foo example
    value: {"foo": "bar"}
  bar:
    summary: A bar example
    value: {"bar": "baz"}

However, in the current implementation of this plugin, it is implemented as an array.

Ref:
In serverless-openapi/src/DefinitionGenerator.ts

if (parameter.example) {
  parameterConfig.example = parameter.example;
// BELOW (Line 227)
} else if (parameter.examples && Array.isArray(parameter.examples)) {
// ABOVE (Line 227)
  parameterConfig.examples = parameter.examples;
}
private attachExamples(target, config) {
// BELOW (Line 307)
  if (target.examples && Array.isArray(target.examples)) {
// ABOVE (Line 307)
    _.merge(config, { examples: _.cloneDeep(target.examples) });
  } else if (target.example) {
    _.merge(config, { example: _.cloneDeep(target.example) });
  }
}
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

1 participant