Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Read default value of a swagger "parameter" object and populate the relevant request parameter value. #66

Open
wxdave opened this issue Dec 14, 2018 · 1 comment

Comments

@wxdave
Copy link

wxdave commented Dec 14, 2018

Example swagger given below. The goal is to read the value foovalue specified for the default parameter of foo, assuming default is in a logical location.

paths:
  /foo-path:
    parameters:
      - $ref: '#/parameters/foo'
    get:
      description: Get a foo    
...
definitions:
...

parameters:
  foo:
    name: foo
    in: query
    required: true
    type: string
    default: foovalue

This would require some magic in AbstractSwagger1XImporter.groovy, assuming complex types (object) would need to be handled in some way. (see line 119 in the below image).

image

The result is that the query parameter's value is populated for all requests (swagger paths) that reference the parameter, as shown below.

image

@wxdave wxdave changed the title Read default value of a swagger "definition" object and populate the relevant request parameter value. Read default value of a swagger "parameter" object and populate the relevant request parameter value. Dec 14, 2018
@wxdave
Copy link
Author

wxdave commented Dec 20, 2018

    <con:resource name="/resource-path" path="/" id="...">
      <con:settings/>
      <con:parameters>
        <con:parameter required="true">
          <con:name>foo</con:name>
          <con:style>QUERY</con:style>
          <con:description>the foo query parameter</con:description>
          <con:value>foovalue</con:value>
        </con:parameter>
      </con:parameters>
...

as defined by schema

    <xsd:complexType name="RestResource">
        <xsd:complexContent>
            <xsd:extension base="tns:ModelItem">
                <xsd:sequence>
                    <xsd:element name="parameters" type="tns:RestParameters">
                    </xsd:element>
                    <xsd:element name="request" type="tns:OldRestRequest"
                                 maxOccurs="unbounded" minOccurs="0">
                    </xsd:element>


                    <xsd:element name="resource" type="tns:RestResource"
                                 maxOccurs="unbounded" minOccurs="0">
                    </xsd:element>

                    <xsd:element name="method" type="tns:RestMethod"
                                 maxOccurs="unbounded" minOccurs="0"></xsd:element>
                </xsd:sequence>
                <xsd:attribute name="path" type="xsd:string"></xsd:attribute>
                <xsd:attribute name="wadlId" type="xsd:string"></xsd:attribute>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

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

No branches or pull requests

1 participant