Document your rest api using swagger - Devoxx 2015johannes_fiala
This session will show you how you can easily document your REST API's using Spring & Swagger.
It will show you how to use the Swagger-Spring integration in a Spring Boot application:
Setup a basic REST API using Spring-Boot together with Swagger-Springfox
Access and test the REST-API using the Swagger-UI client
Generate client code stubs for your language (e.g. Java, PHP, Python, ...) using Swagger-Codegen
Graphically display your REST-API using the Chrome plugin Swagger.ed
Devoxx Belgium Nov. 2015
a step by step tutorial to integrate swagger ui with your Spring service.
swagger ui is a web interface to view , test APIs either rest or soap . you can view an api services see descriptive documentation see example of input like request body and headers
and output like result
Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services. The overarching goal of Swagger is to enable client and documentation systems to update at the same pace as the server. The documentation of methods, parameters, and models are tightly integrated into the server code, allowing APIs to always stay in sync. With Swagger, deploying managing, and using powerful APIs has never been easier.
Swagger APIs for Humans and Robots (Gluecon)Tony Tam
Presentation to Gluecon 2014 about Swagger for API development and adoption of services. Reverb also announced the Swagger 2.0 Working Group, with Apigee as a founding member
Swagger is an open source software framework backed by
a large ecosystem of tools that helps developers
design, build, document and consume RESTful Web
services.
Learn what is coming with the first major revision to the world’s most successful API framework. Tony Tam, the founder of Swagger, discusses the new workflows, tooling, and a more descriptive specification that Swagger 2.0 brings.
Document your rest api using swagger - Devoxx 2015johannes_fiala
This session will show you how you can easily document your REST API's using Spring & Swagger.
It will show you how to use the Swagger-Spring integration in a Spring Boot application:
Setup a basic REST API using Spring-Boot together with Swagger-Springfox
Access and test the REST-API using the Swagger-UI client
Generate client code stubs for your language (e.g. Java, PHP, Python, ...) using Swagger-Codegen
Graphically display your REST-API using the Chrome plugin Swagger.ed
Devoxx Belgium Nov. 2015
a step by step tutorial to integrate swagger ui with your Spring service.
swagger ui is a web interface to view , test APIs either rest or soap . you can view an api services see descriptive documentation see example of input like request body and headers
and output like result
Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services. The overarching goal of Swagger is to enable client and documentation systems to update at the same pace as the server. The documentation of methods, parameters, and models are tightly integrated into the server code, allowing APIs to always stay in sync. With Swagger, deploying managing, and using powerful APIs has never been easier.
Swagger APIs for Humans and Robots (Gluecon)Tony Tam
Presentation to Gluecon 2014 about Swagger for API development and adoption of services. Reverb also announced the Swagger 2.0 Working Group, with Apigee as a founding member
Swagger is an open source software framework backed by
a large ecosystem of tools that helps developers
design, build, document and consume RESTful Web
services.
Learn what is coming with the first major revision to the world’s most successful API framework. Tony Tam, the founder of Swagger, discusses the new workflows, tooling, and a more descriptive specification that Swagger 2.0 brings.
Helps you to understand Swagger and its practical uses for representing REST APIs. You’ll learn some ways to get started. We’ll survey some of the tools and resources for describing REST APIs with Swagger. We’ll talk about what Swagger is (a specification and framework) — and isn’t (merely another doc tool). We’ll talk about the pros and cons of the Swagger-UI. And we’ll look at how Swagger helps people to learn about and explore an API.
Join us for an overview of REST, the Force.com REST API, and learn how to use that REST API with Swagger, a language-agnostic framework for describing, producing, consuming, and visualizing RESTful web services. You'll learn how Swagger can generate a Spring MVC Controller to consume the Force.com REST API, and keep client and documentation systems in sync with the server.
Supporting slide deck for Tony Tam's presentation at I Love APIs 2015. Covers the new swagger project, Swagger Inflector, which allows an API-first definition for REST APIs.
Swagger is a description standard of REST API. I will show you features of Swagger UI, and how to make it out with grape and grape-swagger. At the end introduces PostgREST and emphasizes DRY principle.
Crystal clear service interfaces w/ Swagger/OpenAPIScott Triglia
Learn how to better communicate between Python services. We'll use simple-to-follow examples and go from a service with undocumented endpoints to one which has full docs and validation on requests. Learn how to use Swagger tooling for python, including the bravado (client) and pyramid_swagger (server) libraries. In the end, you'll (hopefully!) find nirvana and make the machines do all the hard work for you.
companion tutorial:
https://medium.com/@augusteo/streamlining-api-with-swagger-io-9f20470d2f42#.twnbi4gr5
Learn about the way Swagger stack and OpenAPI-spec can help you and your team to design, develop and implement API server, client and documentation.
In this talk we will explore what Swagger is, how it can help you streamline your team's API development. The finale will be a live demo on how to deploy Ruby Sinatra API server and Swift iOS client using the Swagger code generation in 5 minutes.
Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.
This talk started with a quick description of APIs and the importance of good documentation. We then introduced Swagger, talked about how/why it helps in solving this process. Finally, we talked about a number of Node.js tools we've built to help make API design, API development and better overall APIs using Node.js and Swagger.
Presented at JavaOne 2016.
Using Swagger has become the most popular way to describe REST APIs across the web, enabling people to more quickly understand and communicate with services, with developer-friendly documentation and rich, autogenerated client SDKs. As the API has moved more into being one of the most important aspects of a service, the Swagger definition has become increasingly more important and essential to the design phase. This presentation explains how the Swagger definition can be used to streamline the iteration process and enable client and server engineers to develop concurrently with complex APIs.
A guide to hiring a great developer to build your first app (redacted version)Oursky
Hiring the right developer for your startup can be wearying. In this bitesized Garage Academy session, Ben Cheng, CEO of Oursky will provide you with all the tips for hiring your first developer -- from app development team structure to recruitment to management.
About the speaker:
Ben Cheng is the CEO of Oursky, a Hong Kong-based app dev studio that helps entrepreneurs and startups turn their ideas into reality. He has driven the company’s vision, strategy, and growth since its inception in 2008, and grown the technology-driven team from 3 to over 40 in Hong Kong and Taipei.
ABOUT OURSKY:
Founded in 2008, Oursky has developed web & mobile apps for startups and enterprises such as ASOS and Thomson Reuters. In 2015, 60% of Oursky's published iOS apps were featured in Apple's App Store and one was selected as a Best of 2013 App.
Test-Driven Documentation for your REST(ful) serviceJeroen Reijn
Building RESTful APIs in Java? Getting tired of the annotation bloat forced upon you by your API specification framework which haunts your RESTful service controllers and model objects? Finding yourself in the situation where your code isn’t always in synch with your specification or vice versa?
RAML and Swagger / OpenAPI are great specifications with powerful and shiny tooling, but they do also really have their downsides when it comes to messing with our code.
Fear not! There are other alternatives worth investigating. In this talk, we’ll take a look at how we recently build, designed and documented a public REST API by doing Test Driven Documentation with some help of AsciiDoc and Spring (Auto) REST Docs.
Helps you to understand Swagger and its practical uses for representing REST APIs. You’ll learn some ways to get started. We’ll survey some of the tools and resources for describing REST APIs with Swagger. We’ll talk about what Swagger is (a specification and framework) — and isn’t (merely another doc tool). We’ll talk about the pros and cons of the Swagger-UI. And we’ll look at how Swagger helps people to learn about and explore an API.
Join us for an overview of REST, the Force.com REST API, and learn how to use that REST API with Swagger, a language-agnostic framework for describing, producing, consuming, and visualizing RESTful web services. You'll learn how Swagger can generate a Spring MVC Controller to consume the Force.com REST API, and keep client and documentation systems in sync with the server.
Supporting slide deck for Tony Tam's presentation at I Love APIs 2015. Covers the new swagger project, Swagger Inflector, which allows an API-first definition for REST APIs.
Swagger is a description standard of REST API. I will show you features of Swagger UI, and how to make it out with grape and grape-swagger. At the end introduces PostgREST and emphasizes DRY principle.
Crystal clear service interfaces w/ Swagger/OpenAPIScott Triglia
Learn how to better communicate between Python services. We'll use simple-to-follow examples and go from a service with undocumented endpoints to one which has full docs and validation on requests. Learn how to use Swagger tooling for python, including the bravado (client) and pyramid_swagger (server) libraries. In the end, you'll (hopefully!) find nirvana and make the machines do all the hard work for you.
companion tutorial:
https://medium.com/@augusteo/streamlining-api-with-swagger-io-9f20470d2f42#.twnbi4gr5
Learn about the way Swagger stack and OpenAPI-spec can help you and your team to design, develop and implement API server, client and documentation.
In this talk we will explore what Swagger is, how it can help you streamline your team's API development. The finale will be a live demo on how to deploy Ruby Sinatra API server and Swift iOS client using the Swagger code generation in 5 minutes.
Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.
This talk started with a quick description of APIs and the importance of good documentation. We then introduced Swagger, talked about how/why it helps in solving this process. Finally, we talked about a number of Node.js tools we've built to help make API design, API development and better overall APIs using Node.js and Swagger.
Presented at JavaOne 2016.
Using Swagger has become the most popular way to describe REST APIs across the web, enabling people to more quickly understand and communicate with services, with developer-friendly documentation and rich, autogenerated client SDKs. As the API has moved more into being one of the most important aspects of a service, the Swagger definition has become increasingly more important and essential to the design phase. This presentation explains how the Swagger definition can be used to streamline the iteration process and enable client and server engineers to develop concurrently with complex APIs.
A guide to hiring a great developer to build your first app (redacted version)Oursky
Hiring the right developer for your startup can be wearying. In this bitesized Garage Academy session, Ben Cheng, CEO of Oursky will provide you with all the tips for hiring your first developer -- from app development team structure to recruitment to management.
About the speaker:
Ben Cheng is the CEO of Oursky, a Hong Kong-based app dev studio that helps entrepreneurs and startups turn their ideas into reality. He has driven the company’s vision, strategy, and growth since its inception in 2008, and grown the technology-driven team from 3 to over 40 in Hong Kong and Taipei.
ABOUT OURSKY:
Founded in 2008, Oursky has developed web & mobile apps for startups and enterprises such as ASOS and Thomson Reuters. In 2015, 60% of Oursky's published iOS apps were featured in Apple's App Store and one was selected as a Best of 2013 App.
Test-Driven Documentation for your REST(ful) serviceJeroen Reijn
Building RESTful APIs in Java? Getting tired of the annotation bloat forced upon you by your API specification framework which haunts your RESTful service controllers and model objects? Finding yourself in the situation where your code isn’t always in synch with your specification or vice versa?
RAML and Swagger / OpenAPI are great specifications with powerful and shiny tooling, but they do also really have their downsides when it comes to messing with our code.
Fear not! There are other alternatives worth investigating. In this talk, we’ll take a look at how we recently build, designed and documented a public REST API by doing Test Driven Documentation with some help of AsciiDoc and Spring (Auto) REST Docs.
Since late 2009 there is Spring 3 published. Some things are new, something keep and something was removed.
Thos talk discuss the changes of the 3rd edition of Spring and introduce Spring Roo, Grails and the SpringSource Toolsuite.
The web has changed! Users spend more time on mobile than on desktops and expect to have an amazing user experience on both. APIs are the heart of the new web as the central point of access data, encapsulating logic and providing the same data and same features for desktops and mobiles. In this workshop, Antonio will show you how to create complex APIs in an easy and quick way using API Platform built on Symfony.
Building Front-End Web Apps that Scale talk from FED London at Yahoo! London.
Concepts and practices that fed into the workflows and application architecture that was core to the BladeRunnerJS toolkit.
How to generate a REST CXF3 application from Swagger ApacheConEU 2016johannes_fiala
This presentation shows you how you can generate server stubs from a Swagger contract,
configure the jaxrs-cxf language to enable Spring-configuration, Spring-Boot integration + tests, automatic BeanValidation on the server side,
generate client code for java and javascript, use/integrate swagger-ui, use swagger2markup
use custom Swagger-Codegen templates + how you can create your own language implementation.
The web has changed! Users spend more time on mobile than on desktops and expect to have an amazing user experience on both. APIs are the heart of the new web as the central point of access data, encapsulating logic and providing the same data and same features for desktops and mobiles.
In this workshop, Paula and Antonio will show you how to create complex APIs in an easy and quick way using API Platform built on Symfony.
Repository: https://github.com/locastic/wscAPI2017
2015-12-02 - WebCamp - Microsoft Azure Logic AppsSandro Pereira
This session will be an introduction to the new Azure Integration features: Logic Apps and also a glimpse about API Apps. They are still in preview but how can we get start using these new features? We will learn how you can use Azure Logic Apps to automate business processes without using code. This course will demonstrate the new graphical designer and how to best take advantage of different Logic App capabilities for your scenarios.
Unlocking the power of the APEX Plugin ArchitectureMatt Nolan
Slides from AUSOUG Webinar 24-Aug-2017. Sorry most of the good stuff was in the Live demos.
Abstract: Get an in depth look into the APEX plugin architecture focusing on region plugins and dynamic actions. In this session you’ll learn about some of the techniques used for developing plugin interoperability and explore the best practices when in comes to designing plugins. We’ll focus on how you can communicate between plugins, increase code centralization, decrease maintenance and plug the functionality gaps in your APEX application.
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java PlatformMike Croft
The Eclipse MicroProfile offers a development platform for users of Enterprise Java who want innovation and modern APIs.
This presentation covers some of the APIs available in the MicroProfile 1.2 specification as at November 2017
All successful APIs have one thing in common: users. And users need tools, including an API Explorer. Join us to learn how to use the Google Blockly library to create an easy to use graphical block-oriented API Explorer that works well with any API, including those with deeply-nested API objects.
API Explorers typically use a form with many drop-down fields to enable different API request options to be chosen and then tried. But for the many APIs that enable requests to include multiple levels of nested objects and arrays, the common API Explorer model breaks down due to the complexity of specifying and displaying the many API objects and their sub-objects, sub-sub-objects, etc.
In this talk, we’ll discuss and demonstrate a solution: using the open source Google Blockly library to create a graphical API Explorer which can cleanly support APIs with any number of nested objects and arrays. The Gang of Four Builder pattern is also used, enabling the API’s complex model to be expressed as an array of simple SDK requests.
The result is an easy to use graphical drag and drop tool for creating and trying complex API requests.
In "Modern development", the presence of client-side code is increasingly present.
It is not least SharePoint, which thanks to the Online version introduced a new development framework based on client-side technologies called "SharePoint Framework " (SPFX).
In This session we will see a brief introduction about why this Framework was created, the principle of operation, the development tools, the programming languages, and the client-side frameworks that you can use to create Customizations such as Web parts and expensions.
Similar to Enhance existing REST APIs (e.g. Facebook Graph API) with code completion using Swagger/Spring- Devoxx 2015 (20)
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
2. @johannes_fiala#Devoxx #Swagger
Enhance REST APIs
• Add API documentation (like WSDL schema)
• Describes the Service/request/response/models
• + add description for others to understand
• In a standardized way = according to Swagger Spec.
• Using a standardized structure, datatype names, references to
models, …
3. @johannes_fiala#Devoxx #Swagger
Enhance REST APIs
Benefits
• Makes the payload predictable
• Allows to use tools using the Swagger-standard
• Use Swagger-UI for exploring the API
• Generate client code with Swagger-Codegen
• Get Code completion for 20+ programming languages
• Ship SDKs in target languages
• Get correct datatypes in client code
• Get Enum support
• Get Compile-time checking of consistency
4. @johannes_fiala#Devoxx #Swagger
How to enhance REST APIs?
• Ask API provider to provide Swagger apidocs
• If using Spring: Springfox-libraries
• If not: see Swagger-Spring integrations
• If not possible:
• Create Swagger apidocs on your own
• Demo Today: Facebook Graph API
• Other REST-API‘s you‘d like to have enhanced?
• Google Maps API?
• ???
5. @johannes_fiala#Devoxx #Swagger
In the next few minutes you‘ll learn
…
• Introduction to Springfox/Swagger-Codegen
• Basic overview of Facebook Graph API
• Step-by-step Demo of using Swagger-Codegen to extract
Metadata & add them to the model
• Extract standard apidocs for Facebook
• Learn about using Swagger-Codegen
• Support of Bean Validation API: add
@NotNull/@Min/@Max by adding your own
BuilderPlugins
6. @johannes_fiala#Devoxx #Swagger
Technology stack
• Spring
• Spring Boot for fast start
• also possible: Spring REST/MVC
• Springfox
• For generating the api-docs
• Swagger UI
• For accessing the api using a browser
• Swagger Codegen commandline
• For generating client code stubs
10. @johannes_fiala#Devoxx #Swagger
Swagger Codegen
• io.swagger.codegen.DefaultGenerator.generate():
• Reads api-docs in json syntax
• Scans each model
• Scans all the model properties
• Then compiles language-specific Mustache templates using a
language-specific Configuration class
• Language specific configuration:
• io.swagger.codegen.languages.*
• Mustache files: src/main/resources
12. @johannes_fiala#Devoxx #Swagger
Facebook Graph API
• Basic docs:
https://developers.facebook.com/docs/graph-
api/overview
• Graph API Explorer:
https://developers.facebook.com/tools/explorer
• Nice for basic testing
• Retrieve your access token
13. @johannes_fiala#Devoxx #Swagger
Extract metadata from the Facebook
Graph API
• Facebook Graph API url:
https://graph.facebook.com/v2.5/microsoft?access_token
=... &fields=name,about,mission
• Get field metadata: add parameter „&metadata=1“
15. @johannes_fiala#Devoxx #Swagger
Extract metadata from the Facebook
Graph API
• Target: Provide Swagger apidocs for Facebook API
• Read metadata
• Add description to fields
• Map field types to standard datatypes
• Add Enumerations
• Swagger Codegen has the Model data available during
processing and can be extended
• Alternative: Json transformation from metadata to
Swagger api
17. @johannes_fiala#Devoxx #Swagger
Preparation work
• Modules of the swagger-springfox-demo:
• Swagger-codegen-2.1.3-facebook
• The customized Swagger-codegen code for Facbeook
• User-rest-service-2.2.2-facebook
• The Spring Boot REST-API application
• User-rest-service-2.2.2-facebook-client-java-codegen
• The generated client stubs
19. @johannes_fiala#Devoxx #Swagger
Define the server proxy
• ConnectorUserFacebookController:
• Uses basic FacebookUser-model (with 2 attributes)
• No need to recode representation class
• Connects to Facebook using Spring Rest
• Try it using Swagger-UI
22. @johannes_fiala#Devoxx #Swagger
Add metadata fields to Swagger-
Codegen
• Add fields listed in metadata
• Add field description
• Map FB field type to Swagger standard datatype
• Extract Enumerations out of description
• Add JSR-303 @NotNull, (@Min, @Max)
• + ???
• Add further Bean Validation Annotations (e.g. Size)?
• Further suggestions?
23. @johannes_fiala#Devoxx #Swagger
Add metadata fields to Swagger-
Codegen
• Important class: DefaultGenerator
• Line: Model model = definitions.get(name);
String access_token =„…";
String url = "https://graph.facebook.com/pivotalsoftware?access_token=" + access_token + "&metadata=1";
FacebookUser user = readJsonFromUrl(url);
for (FacebookField field : user.getMetadata().getFields()) {
propName = field.getName();
// add new virtual fields from Facebook to the model
virtualProperty = new StringProperty();
virtualProperty.setName(propName);
virtualProperty.setDescription(field.getDescription());
model.getProperties().put(propName, virtualProperty);
}
24. @johannes_fiala#Devoxx #Swagger
Add metadata fields to Swagger-
Codegen
• Map Facebook datatypes to Swagger datatypes
// Examples of data type mappings from Facebook-Datatypes to Swagger-Model-Datatypes
if ("bool".equals(field.getType())) {
virtualProperty = new BooleanProperty();
} else if ("unsigned int32".equals(field.getType())){
virtualProperty = new IntegerProperty();
} else {
virtualProperty = new StringProperty();
}
25. @johannes_fiala#Devoxx #Swagger
Add metadata fields to Swagger-
Codegen
• Extract Enum datatypes (e.g. attire)
• Description: "Dress code of the business. Applicable to Restaurants or Nightlife.
Can be one of Casual, Dressy or Unspecified“
StringProperty myStringProperty = (StringProperty)virtualProperty;
String myEnumValues = StringUtils.substringAfter(field.getDescription(), "Can be one of");
myEnumValues = StringUtils.replace(myEnumValues, " or ", ", ");
String[] enumValues = StringUtils.split(myEnumValues);
for (String myEnum : enumValues) {
myStringProperty._enum(myEnum );
}
27. @johannes_fiala#Devoxx #Swagger
View the generated code
• The FacebookUser now has all fields of the Graph API!
@ApiModel(description = "")
public class FacebookUser {
/**
* Information about the Page
**/
@ApiModelProperty(value = "Information about the Page")
@JsonProperty("about")
public String getAbout() {
return about;
}
…
31. @johannes_fiala#Devoxx #Swagger
Adding a custom language
• See JavaFacebookClientCodegen
• Defines template-directory is JavaFacebook
• Now we can modify the Model
• Add @NotNull
• Add @Min, @Max
33. @johannes_fiala#Devoxx #Swagger
Get Swagger apidocs
• Get Swagger apidocs
• Access FB through Proxy using Swagger-UI
• See model definitions in the browser
• Replace the model class „FacebookUser“
• Restart Spring Boot
• Inspect the updated model using the Swagger-UI
http://localhost:8080/swagger/index.html
35. @johannes_fiala#Devoxx #Swagger
Wrapup
• Learned:
• You are able to add fields dynamically to a model class during
client-code-generation, add datatype-mapping and enums
• You are able to access the Facebook Graph API directly
• You are able to add custom languages
• Benefits:
• You can generate client code for every language supported by
Swagger-Codegen
• You have code completion for all model attributes!
36. @johannes_fiala#Devoxx #Swagger
Possible improvements
• Structures (e.g. Location) are currently not part of the
Facebook metadata and need to be created manually as
representation classes
• Some fields are only accessible with specific
permissions, but that‘s also not visible in the metadata
• See Helper-class AssembleFieldsUtil for details
• JSR-303 support needs further improvement
• @Min/@Max, @Size, …
37. @johannes_fiala#Devoxx #Swagger
Support for Beans Validation API
(JSR 303)
• Not yet implemented
• See Issue for discussion:
https://github.com/springfox/springfox/issues/356
• Can be done using extensions (Plugin Builders)
38. @johannes_fiala#Devoxx #Swagger
Support for Beans Validation API
How to add it yourself:
• Using „Plugins“ you can override/add to the behaviour of
Builders for Parameters/the Model
• Add a component implementing the Plugin-Interface,
e.g. ModelPropertyBuilderPlugin
• You get access to the processing context
• You can query for annotations there
• Examples: @NotNull, @Min/@Max
39. @johannes_fiala#Devoxx #Swagger
Support for Beans Validation API
Further available plugins
• Available Plugins for Model/Parameters:
• ModelBuilderPlugin
• ModelPropertyBuilderPlugin
• ParameterBuilderPlugin
40. @johannes_fiala#Devoxx #Swagger
Fine-Tuning Spring Boot
• Spring Boot adds /error path automatically
• Get rid of it using
new Docket(…)…
.apis(Predicates.not(RequestHandlerSelectors.basePack
age("org.springframework.boot")))
41. @johannes_fiala#Devoxx #Swagger
Hot Deploy using Spring Loaded
• Allows hot deploy
• for adding new methods etc.
• Add JVM parameters:
• -javaagent:/path_to_spring-loaded/springloaded-
1.2.4.RELEASE.jar -noverify
• https://github.com/spring-projects/spring-loaded
• http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-hotswapping