JsonPatchDocument Not getting displayed properly in Asp.Net Core 3.1 Web API Swagger - swagger

I have my API documented and versioned previously using Swashbuckle.AspNetCore, Microsoft.AspNetCore.Mvc.Api.Analyzers, Microsoft.AspNetCore.Mvc.Versioning and Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.
Everything was fine but all of a sudden today I noticed that JsonPatchDocument Not getting displayed properly in my swagger. I couldn't figure out what's the root cause. But I suspect some Nuget Package Upgrade?
Previously I remember the JsonPatchDocument in my swagger as something similar below:
{
"Operations": [
{
"value": {},
"path": "string",
"op": "string",
"from": "string"
}
]
}
But now it shows something else,
{
"ContractResolver": {}
}
Please assist on what I'm missing

Make sure you are added the AddNewtonsoftJson in program.cs after install the Microsoft.AspNetCore.Mvc.NewtonsofJson
should be like this :
builder.Services.AddControllers().AddNewtonsoftJson();

Related

How do you configure Destructurama.Attributes .Destructure.UsingAttribues() in JSON from appsettings?

We use appsettings to configure Serilog via JSON, a fairly standard enterprise practice.
But I'm having trouble enabling the UsingAttributes. How does one enable .Destructure.UsingAttributes via JSON config?
I started with a pure Serliog approach, but they indicate that Serilog.Extras.Attributed is deprecated in favor of using Destructurama.Attributed. And in looking at the Destructurama.Attributed github example, I don't understand how to convert that into a JSON configuration. Their example:
var log = new LoggerConfiguration().Destructure.UsingAttributes()
The Serilog documentation for the "Destructure" option is straightforward:
"Destructure": [
{
"Name": "With",
"Args": { "policy": "Sample.CustomPolicy, Sample" }
},
],
However, I don't know what I would use for the "Sample.CustomPolicy, Sample" to get Destructurama to be enabled.
"Destructure": [
{
"Name": "With",
"Args": { "UsingAttributes": WHAT_GOES_HERE}
},
],
I feel like I'm missing something obvious.
I just encountered the same problem and after a few experiments I figured how to have it working using Destructurama.Attributed version 2.0.0 :
You must specify the following using in JSON configuration to make Serilog able to see the library :
"Serilog":
{
"Using":
[
"Destructurama.Attributed"
],
....
}
Inside Serilog configuration, you have to specify this to Destructure to enable the attributes :
"Destructure":
[
{
"Name": "UsingAttributes"
},
....
]

Referencing json from a different file

Maybe I'm not quite understanding swagger quite yet (just did a tutorial). But I am trying to create documentation for an API we are building. Everything points to swagger, so decided to try that. Got it working pretty well. The issue I am having though is moving a schema from the swagger.json file to a seperate file to keep things clean.
The way the documentation has it, you give it a type and then $ref which I did. I then linked it to a file within a folder (of another folder) within the current directory.
{
...
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
...
}
}
}
}
Not exactly this but this gives a good idea of what I had working. If I have this in the same file, this works as I want it to. The issue I am having now is trying to move the properties to another file, as documented in the swagger documentation (maybe this is where I am misunderstanding).
So, I then take away the properties object, and replace it with:
"schema": {
"type": "object",
"$ref": "./components/schemas/staticData"
}
Here's what the external file looks like:
{
"properties": {
"data": {
...
}
}
}
When I run this, I get the following error:
Resolver error at paths./*/*.get.responses.200.schema.$ref
Could not resolve reference: undefined undefined (I obfuscated the path since it's irrelevant and I don't want our paths to be on a public website).
What I am looking for is how the external file needs to be structured so I can put these schemas in a different file and not clog up the root swagger.json file.
EDIT This is the folder structure
public
components
schemas
staticData.json
swagger.json
Thanks in advance.

UI5 application using local proxy throws URN error

I followed this tutorial to create local proxy using node.js library. I got rid of the CORS problem, but I have another problem and it is this one:
I suspect that the problem is caused by defining the data source's uri like this:
"dataSources": {
"Z_ATTENDANCE_SRV": {
"uri": "localhost:8081/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"
}
}
}
I think the problem is cause by "localhost:8081/" prefix in the URI, but I do not know how to get rid of the problem.
Do you have any suggestions?
The solution to this problem is to set port from which the app runs. I run the app in personal WebIDE so my port in 'proxy.js' file is '58513'. Also it is necessary to add 'http://' as a prefix to the data source uri. So my manifest looks like this:
"dataSources": {
"Z_ATTENDANCE_SRV": {
"uri": "http://localhost:58513/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"
}
}
}
However, I am now getting this error which I am not able to resolve.
This looks like an authentication problem. Did you try to add user and password in the request?
"uri": "http://localhost:58513/http://user:password#your.server:8080/sap/opu/odata/SAP/Z_ATTENDANCE_SRV"

Visual Studio error when trying to create MVC application on Azure

I want to create a new MVC application with Visual Studio Community 2015. I've followed this tutorial on how to do this and I've gone as far as creating the application, but after I click 'Create' to create the application, the error message below is displayed.
Is this message referring to the Azure API version for Visual Studio? If so, how should I resolve this? I've looked online and I can't seem to find anything about this error. I'm a newbie at this, so I'm not sure if I've overlooked anything, but I don't seem to according to the tutorial. Any help is greatly appreciated!
UPDATE
The image below shows the SQL API version I've found. It's odd thought, because it does not match the version shown in the error message.
As the error message says the API have to be in correct format yyyy-MM-dd.
API version I was using recently was 2014-04-01 or 2014-04-01-preview. Try any of these when defining SqlServer resouce.
Also have a look at resources.azure.com if you have any SqlServers created and double check the API version from there..
This does not relate to the Azure Sdk version for Visual Studio. It relates to the (in your case) API version used to create SqlServer instance using Azure Resource Manager
Sample SqlServer and database resource node:
"resources": [
{
"name": "[parameters('sqlServerName')]",
"type": "Microsoft.Sql/servers",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ ],
"tags": {
"displayName": "SqlServer"
},
"properties": {
"administratorLogin": "[parameters('sqlDatabaseUserName')]",
"administratorLoginPassword": "[parameters('sqlDatabasePassword')]",
"version": "12.0"
},
"resources": [
{
"name": "AllowAllWindowsAzureIps",
"type": "firewallrules",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
}
},
{
"name": "[parameters('databaseName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"kind": "v12.0",
"dependsOn": [
"[parameters('sqlServerName')]"
],
"tags": {
"displayName": "SqlDatabase"
},
"properties": {
"collation": "[parameters('sqlDatabaseUriNameCollation')]",
"edition": "[parameters('sqlDatabaseUriNameEdition')]",
"maxSizeBytes": "10737418240"
//10 gigs currently
}
}
]
}
Also as #Robert McKee pointed make sure you have latest Azure SDK (2.7.1 or 2.8 released recently)
I'm not sure how, but this evening when I went to try it again, it worked. Thank you all for your answers!

Gcloud::Datastore::ApiError - Api call runQuery is not working

When i run on local. Everything is going okay.
But my appication is not running on cloud provide url
https://<your-project-id>.appspot.com
But working Great on locally.
When first time i deploy its work for me https://<your-project-id>.appspot.com but when i add class and apply add, delete, edit operation its not work on https://<your-project-id>.appspot.com but still working on local.
After deploy
"response": {
"betaSettings": {
"has_docker_image": "True"
},
"name": "apps/trial-project-1103/modules/default/versions/20151021t211200",
"handlers": [
{
"securityLevel": "SECURE_NEVER",
"authFailAction": "AUTH_FAIL_ACTION_REDIRECT",
"urlRegex": ".*",
"login": "LOGIN_OPTIONAL",
"script": {
"scriptPath": "PLACEHOLDER"
}
}
],
"manualScaling": {
"instances": 1
},
"vm": true,
"#type": "type.googleapis.com/google.appengine.v1beta4.Version",
"runtime": "custom",
"id": "20151021t211200",
"resources": {
"diskGb": 10,
"cpu": 0.5,
"memoryGb": 1.2999999523162842
},
"threadsafe": true
},
"done": true,
"name": "apps/trial-project-1103/operations/e302b28c-6984-4362-a823-891f8806e10d",
"metadata": {
"target": "apps/trial-project-1103/modules/default/versions/20151021t211200",
"insertTime": "2015-10-21T16:14:55.935Z",
"method": "google.appengine.v1beta4.Versions.CreateVersion",
"user": "sajjadmurtaza.nxb#gmail.com",
"operationType": "create_version",
"endTime": "2015-10-21T16:17:44.649Z",
"#type": "type.googleapis.com/google.appengine.v1beta4.OperationMetadata"
}
}
Please guide me why this is happening.?
It's impossible to answer your first question without knowing a lot more about your app.
To answer your second, logs are found in the Google Cloud Platform Developers Console. Select your project, then navigate to Monitoring > Logs. You'll be able to see all of the logs for your project.
Have you successfully followed this tutorial?
https://cloud.google.com/ruby/getting-started/hello-world
if you can't ssh into the machine & see the production.log. then, you can enable logging by adding the following to config/environments/production.rb & deploy again
config.consider_all_requests_local = true
This will show the error in the browser itself
Be sure that you've enabled Datastore API in the Developer Console. Also, double check your Project ID and your Dataset ID (which should be the same as the project ID).
In my experience, these are the most common reasons for this error.

Resources