swagger-api / swagger-api/swagger-codegen

Parameters Object class

Open
#7,744 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Other generated clients i have used in the past had an object i could pass to the api function for parameters if there were too many params. I am unable to do this with my swagger 2.0 file. Was this functionality removed?

Swagger-codegen version

swaggerhub editor with codegen

Swagger declaration file content or url
---
swagger: "2.0"
info:
  description: "New Rest API for Rev.IO"
  version: "1.0.0"
  title: "RevIO"
  contact: {}
host: "restapi.rev.io"
basePath: "/v1"
schemes:
- "https"
consumes:
- "application/json"
produces:
- "application/json"
security:
- Basic authentication: []
parameters:
  pageSize:
    name: page_size
    in: query
    description: The number of items to return in the collection.
    required: false
    type: integer
    minimum: 1
    maximum: 500
    default: 10
  page:
    name: page
    in: query
    description: The current page number.
    required: false
    type: integer
    default: 1
  sort:
    name: sort
    in: query
    description: Comma-separated list of fields to sort by. Add a negative sign (-) before a field to indicate descending order.
    required: false
    type: string
    default: 1
paths:
  /addresses:
    get:
      tags:
      - "Addresses"
      summary: "Get list of addresses"
      operationId: "getAddresses"
      responses:
        200:
          description: "Status 200"
          schema:
            $ref: "#/definitions/Addresses"
  /addresses/{id}:
    get:
      tags:
      - "Addresses"
      operationId: "getAddressById"
      parameters: []
      responses:
        200:
          description: "Status 200"
          schema:
            $ref: "#/definitions/Address"
    parameters:
    - name: "id"
      in: "path"
      required: true
      type: "number"
securityDefinitions:
  Basic authentication:
    type: "basic"
definitions:
  Addresses:
    type: "object"
    properties:
      has_more:
        type: "boolean"
      record_count:
        type: "number"
      records:
        type: "array"
        items:
          $ref: "#/definitions/Address"
  Address:
    type: "object"
    properties:
      address_id:
        type: "number"
      customer_id:
        type: "number"
      first_name:
        type: "string"
      middle_initial:
        type: "string"
      last_name:
        type: "string"
      company_name:
        type: "string"
      line_1:
        type: "string"
      line_2:
        type: "string"
      city:
        type: "string"
      state_or_province:
        type: "string"
      postal_code:
        type: "string"
      postal_code_extension:
        type: "string"
      country_code:
        type: "string"
    description: "Single Address Response"
Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/3966

Suggest a fix/enhancement

Add a variable to swagger spec file called "x-optionalParam".

if this value is positive move these params to a separate class

<?php
class GetOptions {

	protected $conditions;
	protected $orderBy;
	protected $page;
	protected $pageSize;

	public function getConditions() {
		return $this->conditions;
	}

	public function setConditions($conditions) {
		$this->conditions = $conditions;
		return $this;
	}

	public function getOrderBy() {
		return $this->orderBy;
	}

	public function setOrderBy($orderBy) {
		$this->orderBy = $orderBy;
		return $this;
	}

	public function getPage() {
		return $this->page;
	}

	public function setPage($page) {
		$this->page = $page;
		return $this;
	}

	public function getPageSize() {
		return $this->pageSize;
	}

	public function setPageSize($pageSize) {
		$this->pageSize = $pageSize;
		return $this;
	}
}
<?php
$options = new GetOptions();
$options-> setPageSize(100);

$referenceApi->getCustomers($options);

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 by reviewing the supplied Swagger 2.0 declaration and the related issue/PR reference 3966, then inspect how the generated PHP client currently handles operation parameters. Done means determining a supported way to group optional parameters into an object and documenting or testing the resulting generated-client usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.