Restful Web Services Development with a Model-Driven Engineering Approach
Total Page:16
File Type:pdf, Size:1020Kb
RESTful Web Services Development with a Model-Driven Engineering Approach RAFAEL CORVEIRA DA CRUZ GONÇALVES Julho de 2018 Instituto Superior de Engenharia do Porto RESTful Web Services Development with a Model- Driven Engineering Approach 1130837, Rafael Gonçalves Dissertation to obtain the Master Degree in Informatics Engineering, Area of Expertise in Software Engineering Porto, july 2018 Instituto Superior de Engenharia do Porto RESTful Web Services Development with a Model- Driven Engineering Approach 1130837, Rafael Gonçalves Dissertation to obtain the Master Degree in Informatics Engineering, Area of Expertise in Software Engineering Supervisor: Isabel Azevedo Porto, july 2018 RESTful Web Services Development with a Model-Driven Engineering Approach Abstract A RESTful web service implementation requires following the constrains inherent to Representational State Transfer (REST) architectural style, which, being a non-trivial task, often leads to solutions that do not fulfill those requirements properly. Model-driven techniques have been proposed to improve the development of complex applications. In model-driven software development, software is not implemented manually based on informal descriptions, but partial or completely generated from formal models derived from metamodels. A model driven approach, materialized in a domain specific language that integrates the OpenAPI specification, an emerging standard for describing REST services, allows developers to use a design first approach in the web service development process, focusing in the definition of resources and their relationships, leaving the repetitive code production process to the automation provided by model-driven engineering techniques. This also allows to shift the creative coding process to the resolution of the complex business rules, instead of the tiresome and error-prone create, read, update, and delete operations. The code generation process covers the web service flow, from the establishment and exposure of the endpoints to the definition of database tables. Key-words: Web service, Model driven engineering, OpenAPI, Resource, Domain specific language, RESTful i RESTful Web Services Development with a Model-Driven Engineering Approach ii RESTful Web Services Development with a Model-Driven Engineering Approach Resumo A implementação de serviços web RESTful requer que as restrições inerentes ao estilo arquitetónico “Representational State Transfer” (REST) sejam cumpridas, o que, sendo usualmente uma tarefa não trivial, geralmente leva a soluções que não atendem a esses requisitos adequadamente. Técnicas orientadas a modelos têm sido propostas para melhorar o desenvolvimento de aplicações complexas. No desenvolvimento de software orientado a modelos, o software não é implementado manualmente com base em descrições informais, mas parcial ou completamente gerado a partir de modelos formais derivados de meta-modelos. Uma abordagem orientada a modelos, materializada através de uma linguagem específica do domínio que integra a especificação OpenAPI, um padrão emergente para descrever serviços REST, permite aos desenvolvedores usar uma primeira abordagem de design no processo de desenvolvimento de serviços da Web, concentrando-se na definição dos recursos e das suas relações, deixando o processo de produção de código repetitivo para a automação fornecida por técnicas de engenharia orientadas a modelos. Isso também permite focar o processo de codificação criativo na resolução e implementação das regras de negócios mais complexas, em vez de nas operações mais repetitivas e propensas a erros: criação, leitura, atualização e remoção de dados. O processo de geração de código abrange o fluxo do serviço web desde o estabelecimento e exposição dos caminhos para os serviços disponíveis até à definição de tabelas de base de dados. Key-words: Serviço web, Engenharia orientada a modelos, OpenAPI, Recurso Linguagem específica do domínio, RESTful iii RESTful Web Services Development with a Model-Driven Engineering Approach iv RESTful Web Services Development with a Model-Driven Engineering Approach Table of contents List of figures ........................................................................................................... vii List of tables ............................................................................................................. ix List of code snippets .............................................................................................. xii Notation and Glossary ........................................................................................... xiv Chapter 1 .................................................................................................................... 1 Introduction.................................................................................................................. 1 1.1 Background and motivation ......................................................................................... 1 1.2 Objectives ................................................................................................................... 2 1.3 Case study .................................................................................................................. 2 1.4 Adopted methodology.................................................................................................. 3 1.5 Contribution to Knowledge .......................................................................................... 4 1.6 Thesis outline .............................................................................................................. 5 Chapter 2 .................................................................................................................... 7 Context ........................................................................................................................ 7 2.1 Problem and opportunities ........................................................................................... 7 2.2 Value analysis and proposition .................................................................................... 9 2.3 RESTful web services ............................................................................................... 19 2.4 Model-Driven Engineering ......................................................................................... 23 2.5 OpenAPI specification ............................................................................................... 24 Chapter 3 .................................................................................................................. 31 MDE in REST web services development ................................................................. 31 3.1 Related work - State of the Art ................................................................................... 31 3.2 Comparative analysis ................................................................................................ 36 3.3 Solution perspective .................................................................................................. 37 3.4 Requirements analysis .............................................................................................. 40 3.5 Adopted technologies ................................................................................................ 42 3.6 Solution evaluation methodology ............................................................................... 45 Chapter 4 .................................................................................................................. 53 DSL Design and implementation ............................................................................... 53 4.1 Common approach .................................................................................................... 53 4.2 Resource-oriented DSL ............................................................................................. 54 4.3 OAS-oriented DSL ..................................................................................................... 62 4.4 Code generation ........................................................................................................ 69 v RESTful Web Services Development with a Model-Driven Engineering Approach 4.5 Broad comparative analysis ....................................................................................... 82 Chapter 5 ................................................................................................................. 85 Solution Evaluation ................................................................................................... 85 5.1 DSLs usability ............................................................................................................ 85 5.2 Code metrics analysis ............................................................................................... 87 5.3 Web service QoS....................................................................................................... 92 Chapter 6 ................................................................................................................. 97 Conclusion and future work ...................................................................................... 97 6.1 Summary ................................................................................................................... 97 6.2 Goals achieved .......................................................................................................... 98 6.3