We are getting "stringstri" instead of "string" type in OpenAPI preview in Swagger UI.
Issue:
when minLength is 7 - we get "strings" in preview
when minLength is 8 - we get "stringst" in preview
when minLength is 9 - we get "stringstr" in preview
Similary it continues.
Expected - only "string".
Sample schema to reproduce the issue:
components:
schemas:
Manufacturer:
required:
- name
properties:
name:
type: string
minLength: 10
maxLength: 2048
Swagger UI displays the following example for this schema:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Widget Adapter",
"releaseDate": "2021-05-17T06:52:27.542Z",
"manufacturer": {
"name": "stringstri",
"homePage": "string",
"phone": "string"
}
}
The name property has minLength: 10 that's why the example value is generated as 10 characters long. The value "string" is only 6 character long so it's not a valid example for a property with minLength >= 7, that's why Swagger UI pads the value in this case.
You can provide your own example value if you want:
properties:
name:
type: string
minLength: 10
maxLength: 2048
example: Acme Corporation # <-----
Related
My use case in the root level json there are 100 fields and out of those 100 fields 90 fields are common and the remaining 10 fields varies for different API's, I need to specify this 90 fields in a global space and on top of that I need to put the 10 different fields
SAMPLE
POST localhost:3000/api/v1/people
{
name: "", age: "", father_name: ""
//other 90 fields
}
POST localhost:3000/api/v1/student
{
//all fields of people and the below fields.
department_name:"", courses_enroled: ""
}
POST localhost:3000/api/v1/teacher
{
//all fields of people and the below fields.
yoe: "", //assume some specific fields
}
I need to define people payload in global space and in student API, I need to ref it.
How to do this in swagger.
whenever I use ref, it replaces al other fields in the same level.
You can extend existing definition in Swagger 3 and higher (not sure which version you are using). Example in yaml (not sure what you use):
definitions:
Response:
description: "Response Object"
type: object
properties:
success:
description: "If action was successful or not"
type: boolean
example: true
message:
description: "Action message"
type: string
example: "Some message"
data:
description: "Response data"
type: Any
nullable: true
ErrorResponse:
allOf:
- $ref: "#/definitions/Response"
- type: object
properties:
success:
example: false
message:
example: "Error message"
data:
example: null
Is it possible to get the labels and priority from a Microsoft Planner task with the Microsoft Graph API?
See screenshot below to have an idea:
Using next endpoint: https://graph.microsoft.com/v1.0/planner/plans/<plan-id>/tasks I get next data:
{
"#odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBBWCc=\"",
"planId": "r4g58er4grregrg7848",
"bucketId": "64g8df54hhktohk487",
"title": "Title of a task",
"orderHint": "545457845775LM",
"assigneePriority": "",
"percentComplete": 0,
"startDateTime": null,
"createdDateTime": "2022-01-07T13:58:14.5355148Z",
"dueDateTime": null,
"hasDescription": true,
"previewType": "description",
"completedDateTime": null,
"completedBy": null,
"referenceCount": 0,
"checklistItemCount": 1,
"activeChecklistItemCount": 3,
"conversationThreadId": null,
"id": "grejgopreg645647",
"createdBy": {
"user": {
"displayName": null,
"id": "74463467-d67d-4512-9086-c9e279dde6ae"
}
},
"appliedCategories": {
"category5": true
},
"assignments": {}
}
I've next comments on this JSON:
What is assigneePriority? When a priority is filled in, will always be an empty string.
What is appliedCategories? Can these categories being used for the labels? But what is category5?
While it's not the most straightforward answer, you can figure out what labels are assigned to a task. You'll need both the planid and taskid to get it.
The appliedCategories are actually the labels applied to a particular task. Their identifieres are just category##. To find the corresponding label name, you'll need to make a call to get the plan details.
Graph API URL: https://graph.microsoft.com/beta/planner/plans/{planid}/details
This will return a JSON object containing each of the categories and their descriptions. You can find more info here about the plannerPlanDetails type. Note: the v1.0 graph endpoint only returns the first 6 categories, while the beta version will return 25.
"categoryDescriptions": {
"category1": "Some name",
"category2": "Some other name",
"category3": "Another",
"category4": null,
...
"category25": null
}
Within the task details, appliedCategories object will contain any labels assigned to that task.
For the priority, you will find a priority property on the task object when using the beta version of the endpoint. It's an integer, but from my testing, the following are the corresponding priority titles
9 - Low
5 - Important
3 - Medium
1 - Urgent
You'll have to do some correlation on your own to match them up, but this is how you can get the information you're looking for.
Using mat-select in multiple mode, is it possible to pre-set the selected values if the values that are part of the select options are objects?
For example if the options in the select are as follows
toppingList: any[] = [
{ id: 1, description: 'Extra cheese' },
{ id: 2, description: 'Mushroom' },
{ id: 3, description: 'Onion' },
{ id: 4, description: 'Pepperoni' },
{ id: 5, description: 'Sausage' },
{ id: 6, description: 'Tomato' }
];
Then can you pre-set the selected values for that mat-select as such?
this.toppings.setValue([{ id: 1, description: 'Extra Cheese' }]);
Taking this stackblitz as an example you see that the the form values are getting set as desired, but the select buttons in the drop down itself are not showing as checked.
Is this even possible, or am I doing something wrong?
as i know for equality of two object, for example in java, you need write equal / hashcode for detect what object equal to another one.
you bind select value to object and typescript could not understand what compare object together. so i change your sample and bind value of options to id and it works!
see this stackblits
I'm trying to have Highcharts do the following: I want to show a column chart with three columns. The two first are to remain constant, the third is to be updated multiple times based on what the user chooses from a drop down-menu.
Choosing from the drop down-menu, I am able to have the third column update. If it's showing "Name 3" initially, choosing "Name 4" from the drop down menu will correctly replace the column. Choosing "Name 5" causes another correct replacement. However, if I then choose "Name 3" again, only the label will update, while the column and the y-value in the tooltip will not. Thus, it will say "Name 3", but use the y-value for "Name 5". How do I fix this behaviour?
The important thing here is user control of column 3. It would be okay to only show 2 column initially, if it's easier.
Code:
var data = {
"10 - Name 1": [700000],
"1001 - Name 2": [750000],
"1000 - Name 3": [800000],
"1002 - Name 4": [900000],
"1003 - Name 5": [950000]
};
var chart = Highcharts.chart('fig8', {
chart: {
type: 'column',
animation: true
},
series: [{
name: "10 - Name 1",
data: data["10 - Name 1"]
}, {
name: "1001 - Name 2",
data: data["1001 - Name 2"]
}, {
name: "1000 - Name 3",
data: data["1000 - Name 3"]
}],
title: {
text: 'Some metric'
},
subtitle: {
text: 'Choose unit from drop down to alter third column'
},
xAxis: {
labels: {
enabled: false
}
}
});
$("#sel").change(function() {
chart.series[2].update({
name: this.value,
data: data[this.value]
});
});
Here's a stripped down example: https://jsfiddle.net/RuneS/soh8vw79/10/
#jlbriggs is correct. Although the docs for update() don't say anything about it, it is mentioned in the docs for setData(): When updating series data, the default behavior is to update the values in the original data array instead of replacing the whole array.
In your case, that means that "Name 3"'s value is overwritten by the others' values when you select from the dropdown. There are at least two ways to fix this:
Force Highcharts to replace the data array by calling setData() with the updatePoints parameter instead of sending the data with update():
$("#sel").change(function() {
var unit = this.value,
val = data[unit],
ser = chart.series[2];
ser.update({ name: unit }, false);
//... false): Replace the series' data array instead of updating its values,
//(which would alter the original array in the global `data` object).
//https://api.highcharts.com/class-reference/Highcharts.Series#setData
ser.setData(val, true, true, false);
});
https://jsfiddle.net/soh8vw79/22
Don't give Highcharts the original array, but a copy of it. That way, updating the values won't affect the original data (similar to #jlbriggs solution). Added bonus: Smooth animation:
...
series: [{
name: "10 - Name 1",
data: data["10 - Name 1"]
}, {
name: "1001 - Name 2",
data: data["1001 - Name 2"]
}, {
name: "1000 - Name 3",
//Here, we use `.slice()` to make a copy of the original array,
//so that future updates don't change the original values in the global `data` object:
data: data["1000 - Name 3"].slice()
}],
...
https://jsfiddle.net/soh8vw79/23
I am trying to use the JSON type provider to access StackOverflow / StackExchange data via the API. It works great, with one caveat. The API has a throttle, which is signaled by a field "backoff" that contains the number of seconds you are supposed to back off until your next request.
As a result, I can't just point the JSON TP to the url, because by default the backoff field is not present. This is how the response typically looks:
{
"items": [
{
"has_synonyms": true,
"user_id": 1144035,
"is_moderator_only": false,
"is_required": false,
"count": 7054,
"name": "sql"
},
{
"has_synonyms": true,
"user_id": 1144035,
"is_moderator_only": false,
"is_required": false,
"count": 16,
"name": "algorithm"
}
],
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693
}
I assumed what I needed to do was to supply a sample which contains both an example without backoff (as above), and one along the lines of this:
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693,
"backoff": 10
}
... so that I get a Backoff Option. However, I am not sure how to structure / prepare the sample to that effect. Help would be much appreciated!
JSON Type Provider has a property SampleIsList, set it to true.
There is a documentation section Parsing Twitter stream about it, JsonProvider please scroll down as there is no way to reference the section directly.
Your sample file should look like this
[{
...
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693
},{
...
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693,
"backoff": 10
}]