how to use jsonschema validation in angular js/rest web service architecture? - json

I am looking to design a client-side json validator through a json schema created for a server (Java backend), so it is important that I use the same schema. What plugins are useful for angularjs to implement json validation on the client?

Try the following angular plugin. It provides a directive to build forms out of JSON Schemas. The schemas can be loaded via a http-service. https://github.com/Textalk/angular-schema-form!

Related

Is there any added advantage of using djangorestframework over JsonResponse?

I am new to Django and API creation. I am trying to figure out if it is better to use djangorestframework or just use JsonResponse. I got the suggestion of djangorestframework from Digital Ocean's tutorial but also found out about JsonResponse, which seems simpler given that I don't have to install another package.
Goal: I would like to be able to provide user information for both web and mobile applications.
I see that there are some reasons provided on this post for djangorestframework, which I pasted below for posteriority.
The common cases for using DRF are:
1)You're creating a public-facing external API for third-party
developers to access the data in your site, and you want to output
JSON they can use in their apps rather than HTML.
2)You're doing mobile development and you want your mobile app to make
GET/PUT/POST requests to a Django backend, and then have your backend
output data (usually as JSON) to the mobile app. Since you don't want
to pass back HTML to the mobile app, you use DRF to effectively create
a REST API that your mobile app can call.
3)You're creating a web app, but you don't want to use the Django
templating language. Instead you want to use the Django ORM but output
everything as JSON and have your frontend created by a JavaScript MVC
framework such as React, Backbone, AngularJS, etc. In those cases, you
can use DRF to output JSON that the JavaScript framework can process.
DRF basically provides you many features to make APIs that you don't have in raw django.
for example:
Serializers: a declarative way(django style like declaring models) of making serializers, when you use JsonResponse you have to tell everywhere what to serialize, with the serializer you have to import it and just use it, also this serializers can be able to save/update objects too. Also support ORM source to connect yours models(think how difficult would be serialize a model with nested relations with JsonResponse).
The Web browsable API, you can see all the availables endpoints.
Third party packages to install and use: https://www.django-rest-framework.org/community/third-party-packages/#existing-third-party-packages.

What are the best/most popular libraries for Json schema validation and serializing/serializing into objects in Node.js?

What are the best/most popular libraries for Json schema validation and serializing/serializing into objects in Node.js or express.js?
you can use validation libraries like https://github.com/geraintluff/tv4, but express and node work with json objects out of the box.

Django rest swagger and json definition

I'm pretty new to Django and I'm currently working on a project where Django-rest-framework is used and the documentation is created with Swagger trough the django-rest-swagger package.
I'm trying to find (or generate) a swagger.json definition file, any idea on where it can be found with this package? I would like to use it to generate client side code.
Thanks
The swagger schema definition can be generated with https://github.com/signalfx/fetch-swagger-schema regardless the api implementation.
You can append ?format=openapi to the end of your docs URL and it will return the raw JSON text instead of the UI.
see here

Creating WSO2 BPEL project for JSON webservices

I have the WSO2 Developer Studio Eclipse Plugin downloaded. And I was looking at this tutorial: http://wso2.com/library/tutorials/2010/07/eclipse-bpel-designer-wso2bps-tutorial/. But it seems to be talking about using SOAP. But my webservices, which are written in PHP(in live servers) are REST using JSON. Accepts data via HTTP GET methods by these webservices and respond back with JSON data.
So how will I implement a BPEL project making use of the JSON webservices? Any ideas or suggestion? Am completely new to this. Thank you.
EDIT
When I created the BPEL Process, I have used HTTP from the dropdown instead of SOAP
WSO2 uses a custom variant of the Apache ODE engine for executing BPEL processes. ODE provides extensions for REST, which you can try out. However, I am not sure if these extensions also support JSON or if they just allow XML data. Also have a look at this answer.

Is there a json validation framework in play based on a specified grammar

An automated system is going to feed the application[Play with Scala] with JSON's and the contract of the integration is that there would be no validation required on JSON's since it will be always deemed right. But for testing purposes when we seed the data more often than not we are not able to send the correct JSONs. We would like to validate the JSON's we receive based on a set of grammars. Is there a library that already does this. Or is there a better way to do this?
Example: Grammar for valid Json :
"header"->[String, mandatory],
"footer"->[String],
"someArray"->Array[String, mandatory],
"someArrayObject"->Array[
{
{"key1"->Int, mandatory},
{"key2"->String}
},
mandatory
]
and passing,
{
"header":"headerContent",
"footer":"footerContent",
"someArray":["str1", "str2"],
"someArrayObject"->[
{"key1":4, "key2":"someStringValue"},
{"key1":5, "key2":"someOtherStringValue"}
]
} // would pass
{
"header":"headerContent",
"footer":"footerContent",
"someArray":["str1", "str2"]
} // would notpass since someArrayObject though declared mandatory is not provided in the sample json
I think play-json will satisfy you play-json
In play-json you don't create a validator as it is, but a json transformer which is a validator in itself. The author of the framework wrote a series of blog-posts to show how to work with it: json-transformers
* Haven't noticed you use play) Play has play-json included by default.
You don't have to roll out your own DSLs. This is why we have schemas. Just like using XML schemas to validate your XML docs, you can define a JSON schema to validate your JSON objects. I had a similar requirement when building a RESTful web service using Play. I solved it by using the JSON Schema Validator library.
I have used the JSON Schema draft v3. The library supports draft v3 and draft v4. You can validate your schemas against possible JSON inputs using a web application that uses the same library. The web app is hosted here.
Also there are pretty nice examples that use the draft v4. You can check them out from here.
In Play 2, I have composed an action that takes the schema resource file name as input. This keeps away a lot of JSON validation code from the controller action itself.
#JsonValidate("user-register.json")
public static Result create() {
...
}
This way, all JSON Validation code stays in one place. Pretty neat :)