I have a swagger docs - openapi.yaml
My task is to write an API. I have schemas in openapi.yaml.
My question is how to convert schemas from openapi.yaml to Django Models?
I have figured out that there is fastapi-codegen for FastAPI. But I use Django Rest Framework, are there any similar generators for DRF?
Related
I'm about to set up an AWS API Gateway via Cloudformation and wondering what is the better solution:
should I use the AWS Resources for Resource and Methods or is the better approach to import the well known OpenAPI (Swagger) file we have into the API Gateway Resource?
From my researches I found out that Using swagger has some limitations (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html) but on the other hand its kind of the standard to create APIs.
So going full in on AWS Cloudformation might have some disadvantages I cannot see right now. Thats why I'm asking for experiences from someone who was in the same situation. Grateful for any guidance...
Merci A
Personally I find the best way to develop api gateway resources is using the Serverless Framework its super easy to use and integrates very easily with other AWS services i.e. Lambda.
Also under the hood serverless is just cloudformation templates so its very flexible.
Nowadays you can write your templates using SAM (Serverless Application Model https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) if you don't like the serverless framework.
Some of the benefits are that you write less cloudformation code and you can locally debug/test your lambdas/step functions.
Here is my two cents on the best practice among your solutions:
While developing products, swagger or apiary are great tools to document your API and quickly mock the API before implementing them. With a mock API and documentation in the hands of (say) a product manager, it becomes easy to get started with a solid plan for development. But tools like swagger can auto-mock an API specification and if you wish to import this specification only to mock an API, then this import feature is a great tool to use, otherwise it is not. Let me explain why.
By importing an API and orchestrating AWS resources directly from swagger, you bring in lots of limitations, the primary one being your development process does not include a framework such as serverless or zappa. This would force us to directly write lambda functions using AWS console or AWS cli, and make the project architecture complicated.
In writing lambda functions without a framework, if we know upfront that our functions would be orthogonal to each other and do not share much common dependencies, then great, this would work, but for any project with (say) a database, functions accessing external API, some endpoints being guarded by an authorizer and having other resources, using a framework is definitely the better option. It is easier to create layers and common code, for example a database wrapper class.
When using any framework, it is better to start with the framework boilerplate and make the implementation to match the documentation. By studying the advantages and limitations of that framework, we can decide if it fits our architecture.
Also, IMO, this method is not widely used, and finding help might be tough later on as the project becomes more complex.
hope this helps.
In Laravel I am used to define my models up front and to perform all actions on them.
However, it seems that most frontend frameworks just use whatever an API reponse provides and store the json data into simple arrays.
The only framework that I found using the model approach is Ember. I am missing this structure in the vue docs. I wonder why nobody seems to care about models. Are they just not that important in the frontend world?
Using models in frontend frameworks is not that common due to JavaScript as a language. There are many benefits to strong typing, which is why there are nowadays multiple ways to add typing to the language.
Vue has support for TypeScript which is a common way to define models in your JavaScript. TypeScript let's you define interfaces with certain types, so that you know that the data you have conforms to your model.
That's where TypeScript comes in handy, Vue supports it, I don't know much about ember but I've found this and Angular has it out of the box. As far as I know backend developers learning front end technologies like Angular and TypeScript over other options because of the coding style.
I currently have developed a few websites (using Django, Flask, Symfony, etc...). I have also developed Ontologies using semantic software (PoolParty) for enterprise size companies.
I would like to use a small ontology to link data currently in the database of a small website. I do not want it connected to the semantic web. I want to keep all data in relational databases, but link the data with an ontology.
Is there a way to do this? Say if I have a simple flask or django app, is there a way to put an ontology and triplestore on top?
How can Jena be used to save triples in a SPARQL endpoint?
I could use SPARQL RestFul API but I wonder if this is also doable using Jena classes.
For SPARQL Update you can do the following:
UpdateRequest update = UpdateFactory.create("# Your SPARQL Updates");
UpdateProcessor processor = UpdateExecutionFactory.createRemote(update, "http://your-domain/update");
processor.execute();
If you are talking about the graph store protocol i.e. uploading entire graphs at once then you can use the DatasetAccessor API e.g.
DatasetAccessor accessor = DatasetAccessorFactory.createHTTP("http://your-domain/ds");
accessor.putModel(m);
If you are talking about MarkLogic specifically (you tagged the question with marklogic), then this github project will likely interest you:
https://github.com/marklogic/marklogic-jena
This library integrates MarkLogic Semantics feature into the Jena RDF
Framework as a persistence and query layer.
Note: not officially released yet currently, but close. Might be worth a look..
HTH!
Is there anything out there that will generate an mvc rest api easily from existing classes or an existing database? Seems like it wouldn't be that difficult to scaffold out various standard operations.
Have a look at spring roo. It allows you to reverse engineer from a database or even generate the database from entities. You should take into account a somewhat steep learning curve if haven't had any use of spring before.