OpenAPITools / OpenAPITools/openapi-generator

Jmeter body request is not valid

Open
#12,243 2 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

Description

Hello guys, I was trying to generate Jmeter API tests from a YAML openapi 3.0.2. it seems everything ok but the request bodies; here is what I can see in the request body part:

${__javaScript("${registrationTypePut}".replace(/'/g\, '"'),)}

Screenshot from 2022-04-26 06-54-55

openapi-generator version

5.4.0

OpenAPI declaration file content or url

I got something like:

openapi: "3.0.2"
info:
  title: company registration types API
  version: "1.0"

components:
  schemas:
    registration-type-post:
      type: object
      required:
        - title
        - country
      properties:
        title:
          type: string
        description:
          type: string
        country:
          type: object
          properties:
            country_id:
              type: string
            state_province_ids:
              type: array
              items:
                type: string
  examples:
    create-registration-type:
      summary: example of post request body
      value:
        title: company-rgt-test-title
        description: Lorem ipsum dolor sit amet
        country:
          country_id: 3905b6f9-70cd-4604-83c5-7d281888a6e9
          state_province_ids:
            [
              1439edbe-e9f0-4ff0-9c70-09c4aa94b74a,
              42d2d458-8ef2-46e3-8458-16b24b6ffe4e,
            ]
paths:
  /registration-types:
    post:
      summary: creating a new company registration type
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/registration-type-post"
            examples:
              create-registration-type:
                $ref: "#/components/examples/create-registration-type"
      responses:
        "201":
          description: created
          content:
            application/json:
              schema:
                type: string
              example: "a29aedf7-f67b-40fb-ab82-217736cc8e75"
Generation Details

I did generate it by a shell installed CLI command like:
openapi-generator-cli generate -i API.yml -g jmeter -o jmeter-client

on Ubuntu 20.04.4, JDK 11, mvn 3.6.3

Related issues/PRs

I don't know but the only issue I did find related to this one maybe be this
but in my case there is no empty body, I can see a piece of code, I think I was expecting example values.

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

Reproduce the JMeter generation with the provided OpenAPI YAML, openapi-generator 5.4.0, and the documented CLI command on Ubuntu. Inspect the JMeter generator output and its handling of request-body examples; done means the generated request contains a valid body rather than the shown JavaScript expression.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.