OpenAPITools / OpenAPITools/openapi-generator

[BUG][SCALA][GATLING] No way to get bodyparams from operation

Open
#13,826 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [ X] Have you provided a full/minimal spec to reproduce the issue?
  • [X ] Have you validated the input using an OpenAPI validator (example)?
  • [X ] Have you tested with the latest master to confirm the issue still exists?
  • [ X] Have you searched for related issues/PRs?
  • [ X] What's the actual output vs expected output?
  • [ X] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

There is no parameters in requestBody or parameters when printed.
I cannot find a way to get them

In the code there is only these commented lines :

/* TODO need to revise below as body is no longer in the parameter
                    if (parameter.getIn().equalsIgnoreCase("body")) {
                        BodyParameter bodyParameter = (BodyParameter) parameter;
                        Model model = bodyParameter.getSchema();
                        if (model instanceof RefModel) {
                            String[] refArray = model.getReference().split("\\/");
                            operation.setVendorExtension("x-gatling-body-object", refArray[refArray.length - 1] + ".toStringBody");
                            Set<String> bodyFeederParams = new HashSet<>();
                            Set<String> sessionBodyVars = new HashSet<>();
                            for (Map.Entry<String, Model> modelEntry : swagger.getDefinitions().entrySet()) {
                                if (refArray[refArray.length - 1].equalsIgnoreCase(modelEntry.getKey())) {
                                    for (Map.Entry<String, Property> propertyEntry : modelEntry.getValue().getProperties().entrySet()) {
                                        bodyFeederParams.add(propertyEntry.getKey());
                                        sessionBodyVars.add("\"${" + propertyEntry.getKey() + "}\"");
                                    }
                                }
                            }
                            operation.setVendorExtension("x-gatling-body-feeder", operation.getOperationId() + "BodyFeeder");
                            operation.setVendorExtension("x-gatling-body-feeder-params", StringUtils.join(sessionBodyVars, ","));
                            try {
                                FileUtils.writeStringToFile(
                                    new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + "bodyParams.csv"),
                                    StringUtils.join(bodyFeederParams, ","),
                                    StandardCharsets.UTF_8
                                );
                            } catch (IOException ioe) {
                                LOGGER.error("Could not create feeder file for operationId" + operation.getOperationId(), ioe);
                            }

                        } else if (model instanceof ArrayModel) {
                            operation.setVendorExtension("x-gatling-body-object", "StringBody(\"[]\")");
                        } else {
                            operation.setVendorExtension("x-gatling-body-object", "StringBody(\"{}\")");
                        }

                    }
                    */

Have you an idea how i can get these parameters ?

Thanks in advance,

Sincerely yours

openapi-generator version

latest openapi generator

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Scala Gatling generator code containing the commented body-parameter block and trace how requestBody and parameters are represented for an operation. Reproduce the issue with a minimal OpenAPI specification, then verify that body parameters are exposed in the generated Gatling output and that the relevant generator tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.