swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.09k stars 6.03k forks source link

Generate .jmx (Jmeter file) from .yaml #8313

Open mickteul opened 6 years ago

mickteul commented 6 years ago

Hi everyone, I try to create my own template (api.mustache) in order to generate a .jmx (Jmeter test file) to test my API REST. My problem is to collect aproperties of a body type object parameter.

Here is a part of my .yaml :

/dossiers/{dossierId}/dossiers:
    post:
      tags:
      - DossierService
      summary: Ajouter un sous-dossier.
      operationId: addDossier
      consumes:
      - application/json
      produces:
      - application/json
      parameters:
      - name: dossier
        in: body
        required: true
        schema:
          type: object
          required:
          - name
          properties:
            name:
              type: string
              maxLength: 200
              description: Le nom du nouveau dossier.

I want to extract the string "name" who is in properties of parameter "Dossier", but I can't do that...

When I use this code in my api.mustache, my variable {{basename}} is equal at "Dossier"...

{{#operations}}
{{#operation}}
{{#bodyParams}}
               <elementProp name="{{baseName}}" elementType="HTTPArgument">
{{/bodyParams}}
{{/operation}}
{{/operations}}

I used DebugOperation et DebugModel to identify which variable I can use and i see my name variable in DebugModel but I can't use it (I tried use {{#models}}, {{#model}}, {{#var}}, etc...)

Somebody can help me ??

Mickael

Swagger-codegen version --> swagger-codegen-2.3.1
HugoMario commented 6 years ago

hey @mickteul i'm not familiar with Jmeter, but trying with Java language. i saw that as a body a model class (Dossier) is created as a bodyParam, maybe that can give you a guide.