I want to specify the default JSON body for a POST request in Swagger-PHP. My annotations look like this:
/**
* Setup order
*
* #SWG\Post(
* path="/order/setup",
* operationId="setupOrder",
* tags={"Orders"},
* summary="Setup an order with status draft.",
* description="Setup an order with status draft",
* consumes={"application/json"},
* #SWG\Parameter(
* name="body",
* in="body",
* default="{}",
* description="Json order info body (customer and products info)",
* required=true,
* #SWG\Schema(type="string")
* ),
* #SWG\Response(
* response=200,
* description="successful operation"
* ),
* #SWG\Response(response=400, description="Bad request"),
* security={
* {"api_key_security_example": {}}
* }
* )
*
*/
As you can see I'm trying to achieve the default value with default="{}", but Swagger UI ignores this value and places 'string' instead as default value:
How can I change the 'string' part to a default JSON object?
You can achieve as you expected by modifying your #SWG\Parameter().
Example (look at example of the property):
* #SWG\Parameter(
* name="body",
* in="body",
* description="User email used to create account.",
* required=true,
* #SWG\Schema(#SWG\Property(property="email", type="string", example="email#example.com")),
* )
You can use like below.
/**
* Setup order
* #SWG\Post(
* path="/order/setup",
* operationId="setupOrder",
* tags={"Orders"},
* summary="Setup an order with status draft.",
* description="Setup an order with status draft",
* consumes={"application/json"},
* #SWG\Parameter(
* name="body",
* in="body",
* default="{}",
* description="Json order info body (customer and products info)",
* required=true,
* #SWG\Schema(ref="#/definitions/testDefinitions")
* ),
* #SWG\Response(
* response=200,
* description="successful operation"
* ),
* #SWG\Response(response=400, description="Bad request"),
* security={
* {"api_key_security_example": {}}
* }
* )
* #SWG\Definition(
* definition="PlanResponse",
* example={
* "type":"string"
* }
* )
*/
Thanks,
Related
So, I have the following security vulnerability in activesupport, activerecord and actionpack.
Name: actionpack
Version: 5.2.8.1
CVE: CVE-2023-22792
GHSA: GHSA-p84v-45xj-wwqj
Criticality: Unknown
URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
Title: ReDoS based DoS vulnerability in Action Dispatch
Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
Name: activerecord
Version: 5.2.8.1
CVE: CVE-2022-44566
GHSA: GHSA-579w-22j4-4749
Criticality: Unknown
URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
Title: Denial of Service Vulnerability in ActiveRecord’s PostgreSQL adapter
Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
Name: activesupport
Version: 5.2.8.1
CVE: CVE-2023-22796
GHSA: GHSA-j6gc-792m-qgm2
Criticality: Unknown
URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
Title: ReDoS based DoS vulnerability in Active Support’s underscore
Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
my rails version from gemfile
gem 'rails', '~> 5.2.8', '>= 5.2.8.1'
as the solution suggests upgrade to '~> 5.2.8, >= 5.2.8.15' seems to be the next step. so I changed the gemfile as follows:
gem 'rails', '~> 5.2.8', '>= 5.2.8.15'
and then bundle install' | I've also done bundle update` which produces the same output as the following
Fetching gem metadata from https://rubygems.org/..........
Could not find gem 'rails (~> 5.2.8, >= 5.2.8.15)' in rubygems repository https://rubygems.org/ or installed locally.
The source contains the following gems matching 'rails':
* rails-0.8.0
* rails-0.8.5
* rails-0.9.0
* rails-0.9.1
* rails-0.9.2
* rails-0.9.3
* rails-0.9.4
* rails-0.9.4.1
* rails-0.9.5
* rails-0.10.0
* rails-0.10.1
* rails-0.11.0
* rails-0.11.1
* rails-0.12.0
* rails-0.12.1
* rails-0.13.0
* rails-0.13.1
* rails-0.14.1
* rails-0.14.2
* rails-0.14.3
* rails-0.14.4
* rails-1.0.0
* rails-1.1.0
* rails-1.1.1
* rails-1.1.2
* rails-1.1.3
* rails-1.1.4
* rails-1.1.5
* rails-1.1.6
* rails-1.2.0
* rails-1.2.1
* rails-1.2.2
* rails-1.2.3
* rails-1.2.4
* rails-1.2.5
* rails-1.2.6
* rails-2.0.0
* rails-2.0.1
* rails-2.0.2
* rails-2.0.4
* rails-2.0.5
* rails-2.1.0
* rails-2.1.1
* rails-2.1.2
* rails-2.2.2
* rails-2.2.3
* rails-2.3.2
* rails-2.3.3
* rails-2.3.4
* rails-2.3.5
* rails-2.3.6
* rails-2.3.7
* rails-2.3.8.pre1
* rails-2.3.8
* rails-2.3.9.pre
* rails-2.3.9
* rails-2.3.10
* rails-2.3.11
* rails-2.3.12
* rails-2.3.14
* rails-2.3.15
* rails-2.3.16
* rails-2.3.17
* rails-2.3.18
* rails-3.0.0.beta
* rails-3.0.0.beta2
* rails-3.0.0.beta3
* rails-3.0.0.beta4
* rails-3.0.0.rc
* rails-3.0.0.rc2
* rails-3.0.0
* rails-3.0.1
* rails-3.0.2
* rails-3.0.3
* rails-3.0.4.rc1
* rails-3.0.4
* rails-3.0.5.rc1
* rails-3.0.5
* rails-3.0.6.rc1
* rails-3.0.6.rc2
* rails-3.0.6
* rails-3.0.7.rc1
* rails-3.0.7.rc2
* rails-3.0.7
* rails-3.0.8.rc1
* rails-3.0.8.rc2
* rails-3.0.8.rc4
* rails-3.0.8
* rails-3.0.9.rc1
* rails-3.0.9.rc3
* rails-3.0.9.rc4
* rails-3.0.9.rc5
* rails-3.0.9
* rails-3.0.10.rc1
* rails-3.0.10
* rails-3.0.11
* rails-3.0.12.rc1
* rails-3.0.12
* rails-3.0.13.rc1
* rails-3.0.13
* rails-3.0.14
* rails-3.0.15
* rails-3.0.16
* rails-3.0.17
* rails-3.0.18
* rails-3.0.19
* rails-3.0.20
* rails-3.1.0.beta1
* rails-3.1.0.rc1
* rails-3.1.0.rc2
* rails-3.1.0.rc3
* rails-3.1.0.rc4
* rails-3.1.0.rc5
* rails-3.1.0.rc6
* rails-3.1.0.rc8
* rails-3.1.0
* rails-3.1.1.rc1
* rails-3.1.1.rc2
* rails-3.1.1.rc3
* rails-3.1.1
* rails-3.1.2.rc1
* rails-3.1.2.rc2
* rails-3.1.2
* rails-3.1.3
* rails-3.1.4.rc1
* rails-3.1.4
* rails-3.1.5.rc1
* rails-3.1.5
* rails-3.1.6
* rails-3.1.7
* rails-3.1.8
* rails-3.1.9
* rails-3.1.10
* rails-3.1.11
* rails-3.1.12
* rails-3.2.0.rc1
* rails-3.2.0.rc2
* rails-3.2.0
* rails-3.2.1
* rails-3.2.2.rc1
* rails-3.2.2
* rails-3.2.3.rc1
* rails-3.2.3.rc2
* rails-3.2.3
* rails-3.2.4.rc1
* rails-3.2.4
* rails-3.2.5
* rails-3.2.6
* rails-3.2.7.rc1
* rails-3.2.7
* rails-3.2.8.rc1
* rails-3.2.8.rc2
* rails-3.2.8
* rails-3.2.9.rc1
* rails-3.2.9.rc2
* rails-3.2.9.rc3
* rails-3.2.9
* rails-3.2.10
* rails-3.2.11
* rails-3.2.12
* rails-3.2.13.rc1
* rails-3.2.13.rc2
* rails-3.2.13
* rails-3.2.14.rc1
* rails-3.2.14.rc2
* rails-3.2.14
* rails-3.2.15.rc1
* rails-3.2.15.rc2
* rails-3.2.15.rc3
* rails-3.2.15
* rails-3.2.16
* rails-3.2.17
* rails-3.2.18
* rails-3.2.19
* rails-3.2.20
* rails-3.2.21
* rails-3.2.22
* rails-3.2.22.1
* rails-3.2.22.2
* rails-3.2.22.3
* rails-3.2.22.4
* rails-3.2.22.5
* rails-4.0.0.beta1
* rails-4.0.0.rc1
* rails-4.0.0.rc2
* rails-4.0.0
* rails-4.0.1.rc1
* rails-4.0.1.rc2
* rails-4.0.1.rc3
* rails-4.0.1.rc4
* rails-4.0.1
* rails-4.0.2
* rails-4.0.3
* rails-4.0.4.rc1
* rails-4.0.4
* rails-4.0.5
* rails-4.0.6.rc1
* rails-4.0.6.rc2
* rails-4.0.6.rc3
* rails-4.0.6
* rails-4.0.7
* rails-4.0.8
* rails-4.0.9
* rails-4.0.10.rc1
* rails-4.0.10.rc2
* rails-4.0.10
* rails-4.0.11
* rails-4.0.11.1
* rails-4.0.12
* rails-4.0.13.rc1
* rails-4.0.13
* rails-4.1.0.beta1
* rails-4.1.0.beta2
* rails-4.1.0.rc1
* rails-4.1.0.rc2
* rails-4.1.0
* rails-4.1.1
* rails-4.1.2.rc1
* rails-4.1.2.rc2
* rails-4.1.2.rc3
* rails-4.1.2
* rails-4.1.3
* rails-4.1.4
* rails-4.1.5
* rails-4.1.6.rc1
* rails-4.1.6.rc2
* rails-4.1.6
* rails-4.1.7
* rails-4.1.7.1
* rails-4.1.8
* rails-4.1.9.rc1
* rails-4.1.9
* rails-4.1.10.rc1
* rails-4.1.10.rc2
* rails-4.1.10.rc3
* rails-4.1.10.rc4
* rails-4.1.10
* rails-4.1.11
* rails-4.1.12.rc1
* rails-4.1.12
* rails-4.1.13.rc1
* rails-4.1.13
* rails-4.1.14.rc1
* rails-4.1.14.rc2
* rails-4.1.14
* rails-4.1.14.1
* rails-4.1.14.2
* rails-4.1.15.rc1
* rails-4.1.15
* rails-4.1.16.rc1
* rails-4.1.16
* rails-4.2.0.beta1
* rails-4.2.0.beta2
* rails-4.2.0.beta3
* rails-4.2.0.beta4
* rails-4.2.0.rc1
* rails-4.2.0.rc2
* rails-4.2.0.rc3
* rails-4.2.0
* rails-4.2.1.rc1
* rails-4.2.1.rc2
* rails-4.2.1.rc3
* rails-4.2.1.rc4
* rails-4.2.1
* rails-4.2.2
* rails-4.2.3.rc1
* rails-4.2.3
* rails-4.2.4.rc1
* rails-4.2.4
* rails-4.2.5.rc1
* rails-4.2.5.rc2
* rails-4.2.5
* rails-4.2.5.1
* rails-4.2.5.2
* rails-4.2.6.rc1
* rails-4.2.6
* rails-4.2.7.rc1
* rails-4.2.7
* rails-4.2.7.1
* rails-4.2.8.rc1
* rails-4.2.8
* rails-4.2.9.rc1
* rails-4.2.9.rc2
* rails-4.2.9
* rails-4.2.10.rc1
* rails-4.2.10
* rails-4.2.11
* rails-4.2.11.1
* rails-4.2.11.2
* rails-4.2.11.3
* rails-5.0.0.beta1
* rails-5.0.0.beta1.1
* rails-5.0.0.beta2
* rails-5.0.0.beta3
* rails-5.0.0.beta4
* rails-5.0.0.racecar1
* rails-5.0.0.rc1
* rails-5.0.0.rc2
* rails-5.0.0
* rails-5.0.0.1
* rails-5.0.1.rc1
* rails-5.0.1.rc2
* rails-5.0.1
* rails-5.0.2.rc1
* rails-5.0.2
* rails-5.0.3
* rails-5.0.4.rc1
* rails-5.0.4
* rails-5.0.5.rc1
* rails-5.0.5.rc2
* rails-5.0.5
* rails-5.0.6.rc1
* rails-5.0.6
* rails-5.0.7
* rails-5.0.7.1
* rails-5.0.7.2
* rails-5.1.0.beta1
* rails-5.1.0.rc1
* rails-5.1.0.rc2
* rails-5.1.0
* rails-5.1.1
* rails-5.1.2.rc1
* rails-5.1.2
* rails-5.1.3.rc1
* rails-5.1.3.rc2
* rails-5.1.3.rc3
* rails-5.1.3
* rails-5.1.4.rc1
* rails-5.1.4
* rails-5.1.5.rc1
* rails-5.1.5
* rails-5.1.6
* rails-5.1.6.1
* rails-5.1.6.2
* rails-5.1.7.rc1
* rails-5.1.7
* rails-5.2.0.beta1
* rails-5.2.0.beta2
* rails-5.2.0.rc1
* rails-5.2.0.rc2
* rails-5.2.0
* rails-5.2.1.rc1
* rails-5.2.1
* rails-5.2.1.1
* rails-5.2.2.rc1
* rails-5.2.2
* rails-5.2.2.1
* rails-5.2.3.rc1
* rails-5.2.3
* rails-5.2.4.rc1
* rails-5.2.4
* rails-5.2.4.1
* rails-5.2.4.2
* rails-5.2.4.3
* rails-5.2.4.4
* rails-5.2.4.5
* rails-5.2.4.6
* rails-5.2.5
* rails-5.2.6
* rails-5.2.6.1
* rails-5.2.6.2
* rails-5.2.6.3
* rails-5.2.7
* rails-5.2.7.1
* rails-5.2.8
* rails-5.2.8.1
* rails-6.0.0.beta1
* rails-6.0.0.beta2
* rails-6.0.0.beta3
* rails-6.0.0.rc1
* rails-6.0.0.rc2
* rails-6.0.0
* rails-6.0.1.rc1
* rails-6.0.1
* rails-6.0.2.rc1
* rails-6.0.2.rc2
* rails-6.0.2
* rails-6.0.2.1
* rails-6.0.2.2
* rails-6.0.3.rc1
* rails-6.0.3
* rails-6.0.3.1
* rails-6.0.3.2
* rails-6.0.3.3
* rails-6.0.3.4
* rails-6.0.3.5
* rails-6.0.3.6
* rails-6.0.3.7
* rails-6.0.4
* rails-6.0.4.1
* rails-6.0.4.2
* rails-6.0.4.3
* rails-6.0.4.4
* rails-6.0.4.5
* rails-6.0.4.6
* rails-6.0.4.7
* rails-6.0.4.8
* rails-6.0.5
* rails-6.0.5.1
* rails-6.0.6
* rails-6.0.6.1
* rails-6.1.0.rc1
* rails-6.1.0.rc2
* rails-6.1.0
* rails-6.1.1
* rails-6.1.2
* rails-6.1.2.1
* rails-6.1.3
* rails-6.1.3.1
* rails-6.1.3.2
* rails-6.1.4
* rails-6.1.4.1
* rails-6.1.4.2
* rails-6.1.4.3
* rails-6.1.4.4
* rails-6.1.4.5
* rails-6.1.4.6
* rails-6.1.4.7
* rails-6.1.5
* rails-6.1.5.1
* rails-6.1.6
* rails-6.1.6.1
* rails-6.1.7
* rails-6.1.7.1
* rails-6.1.7.2
* rails-7.0.0.alpha1
* rails-7.0.0.alpha2
* rails-7.0.0.rc1
* rails-7.0.0.rc2
* rails-7.0.0.rc3
* rails-7.0.0
* rails-7.0.1
* rails-7.0.2
* rails-7.0.2.1
* rails-7.0.2.2
* rails-7.0.2.3
* rails-7.0.2.4
* rails-7.0.3
* rails-7.0.3.1
* rails-7.0.4
* rails-7.0.4.1
* rails-7.0.4.2
What am I doing wrong. how can i upgrade those three (activesupport, activerecord and actionpack)?
After defining new rules and versions in your Gemfile, run:
bundle update rails
This will update all direct dependencies of Rails too.
But! be sure the version exists on RubyGems: https://rubygems.org/gems/rails/versions (it seems that v5.2.8.15 does not exist).
I am using "nelmio/api-doc-bundle" 4.9 and I need to pass multi-dimenional array using swagger. In postman I am passing like this.
So far, I have tried this in swagger.
* #OA\Parameter(
* name="banner[]",
* in="query",
* description="Banner information",
* required=true,
* #OA\Schema(
* type="array",
* #OA\Items(
* type="array",
* #OA\Items(type="string", propertyNames="startDate")
* )
* ),
* ),
i'm using Swagger to document my Lumen API and im using annotations. The thing is, i don't know how to achieve the structure that you can see on the picture with annotations
Can anyone help me with this?
I finally found the answer to this and how to get the structure that i wanted:
#OA\RequestBody(
* #OA\JsonContent(
* type="object",
* #OA\Property(property="idNumber", type="string"),
* #OA\Property(property="ClientId", type="string"),
* #OA\Property(property="inspection", type="array",
* #OA\Items(type="object", properties = {
* #OA\Property(property="Color", type="string"),
* #OA\Property(property="time", type="string"),
* #OA\Property(property="place", type="string"),
* #OA\Property(property="issue", type="string"),
* #OA\Property(property="details", type="string"),
* }),
* ),
* #OA\Property(property="detailId", type="string"),
* #OA\Property(property="WayPayment", type="array",
* #OA\Items(type="object", properties = {
* #OA\Property(property="banking", type="string"),
* #OA\Property(property="numbercard", type="string"),
* #OA\Property(property="numberpayment", type="string"),
* }),
* ),
* ),
* ),
/**
* #SWG\POST(
* path="/visa-entry/calculate",
* operationId="visaEntryCalculate",
* tags={"Visa Entry"},
* summary="Calculate the price for an array of visa entries",
* description="Calculate the price for an array of visa entries",
*
* #SWG\Parameter(
* name="entries",
* in="body",
* description="Visa Entry IDs to calculate to total price",
* required=true,
* #SWG\Schema(
* type="array",
* #SWG\Items(type="number")
* ),
* collectionFormat="multi"
* ),
*
* #SWG\Response(
* response=200,
* description="OK"
* ),
*
* #SWG\Response(
* response=400,
* description="Bad request"
* ),
* )
*
* Calculates a visa entry
*/
What I'm trying to do is to receive an Array of numbers with the key entries.
entries: [1, 2, 3]
This docblock renders the following CURL.
curl -X POST "app.test/visa-entry/calculate" -H "accept: application/json" -H "Content-Type: application/json" -H "X-CSRF-TOKEN: " -d "[0]"
How can I get it to send the array with the key entries?
If you don't want the client to post the array directly in the request-body, but with a key, you'll need to specify the in=body parameter as type="object" and define the array as a property of that schema.
Like this:
/**
* #SWG\POST(
* path="/visa-entry/calculate",
* operationId="visaEntryCalculate",
* tags={"Visa Entry"},
* summary="Calculate the price for an array of visa entries",
* description="Calculate the price for an array of visa entries",
*
* #SWG\Parameter(
* in="body",
* name="json",
* description="Visa Entry IDs to calculate to total price",
* required=true,
* #SWG\Schema(
* type="object",
* #SWG\Property(
* property="entries",
* type="array",
* #SWG\Items(type="number")
* )
* ),
* collectionFormat="multi"
* ),
*
* #SWG\Response(
* response=200,
* description="OK"
* ),
*
* #SWG\Response(
* response=400,
* description="Bad request"
* ),
* )
*
* Calculates a visa entry
*/
I want to generate a grid with views. I need from 1 row, 1 column up to 3 rows, 6 columns.
my code now is working if i want, that all views are in their place:
* * * * *
* * * * *
* * * * *
but i want to leave some places empty, for example i want to do things like:
* * * * *
* *
* * * * *
or:
* * * *
* *
* *
my code:
.m
-(void) generateCardViews {
int positionsLeftInRow = CARDS_PER_ROW;
int j = 0; // j = ROWNUMBER (j = 0) = ROW1, (j = 1) = ROW2...
for (int i = 0; i < [self.gameModel.cards count]; i++) {
NSInteger value = ((CardModel *)self.gameModel.cards[i]).value;
CGFloat x = (i % CARDS_PER_ROW) * 121 + (i % CARDS_PER_ROW) * 40 + 285;
if (j == 1) {
x += 80; // set additional indent (horizontal displacement)
}
if (j == 2) {
x -= 160;
}
CGFloat y = j * 122 + j * 40 + 158;
CGRect frame = CGRectMake(x, y, 125, 125);
CardView *cv = [[CardView alloc] initWithFrame:frame andPosition:i andValue:value];
}
how can i do this?
EDIT:
Now with my Code:
if gameModel.cards count = 18 (get this from my model) and if CARS_PER_ROW = 6 i get:
* * * * * *
* * * * * *
* * * * * *
if gameModel.cards count = 12 (get this from my model) and if CARS_PER_ROW = 5 i get:
* * * * *
* * * * *
* *
I think you can create all the frame's in an arrary, and then generate buttons from the arrary.