The swagger docs site shows an example for this case, but it does not follow through all the way to show the definition of the Pet
schema.
E.g.:
paths:
/pets:
post:
summary: Add a new pet
requestBody:
$ref: '#/components/requestBodies/PetBody'
/pets/{petId}
put:
summary: Update a pet
parameters: [ ... ]
requestBody:
$ref: '#/components/requestBodies/PetBody'
components:
requestBodies:
PetBody:
description: A JSON object containing pet information
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
I don't understand where the request body parameter names go in this scenario. I want to see the definition of #/components/schemas/Pet
. For query parameters you have the components/parameters
where you can define a name
and a schema
for each parameter. But I don't see the equivalent for the request body parameters. For example if I have a POST /api/pets
with an application/json
body of:
{ "name": "Fluffy", "type": "cat", "legs": 4 }
Where do I describe the parameters name
, type
and legs
including their names?
Also on an unrelated topic it would be nice if there was a tag for OpenAPI v3.0 (not sure how to create one)
Also possible related question here.
答案 0 :(得分:1)
在仔细研究过这些招摇过的文档之后,我认为 public partial class MainPage : ContentPage
{
ObservableCollection<string> _images = new ObservableCollection<string>();
//List<string> _images = new List<string>();
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
//Change List and add ObservableCollection here
MessagingCenter.Subscribe<App, ObservableCollection<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelected", (s, images) =>
{
listItems.FlowItemsSource = images;
_images = images;
});
}
protected override void OnDisappearing()
{
base.OnDisappearing();
MessagingCenter.Unsubscribe<App, List<string>>(this, "ImagesSelected");
}
public void RemoveImage(Object sender, EventArgs args)
{
var i = (Image)sender;
_images.Remove(i.ClassId);
}
}
}
模式将是:
Pet
我错过了components:
schemas:
Pet:
type: object
properties:
name:
type: string
type:
type: string
legs:
type: integer
required:
- type
属性。