curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs
nodejs -v
nodejs -v
v10.0.0
That's it :-)
v10.0.0
That's it :-)
sudo apt-get update
sudo apt-get update | grep "Failed"
E: The repository 'http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic Release' E: The repository 'http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu bionic Release'
-e 'http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic'
/etc/apt/sources.list.d/colingille-ubuntu-freshlight-bionic.list:1:deb http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic main /etc/apt/sources.list.d/colingille-ubuntu-freshlight-bionic.list:2:# deb-src http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic main /etc/apt/sources.list.d/colingille-ubuntu-freshlight-bionic.list.save:1:deb http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic main /etc/apt/sources.list.d/colingille-ubuntu-freshlight-bionic.list.save:2:# deb-src http://ppa.launchpad.net/colingille/freshlight/ubuntu bionic main
Comment or delete the PPA repository in the different listed files.
<dependencies>
<!-- annotations from the Checker Framework: nullness, interning, locking, ... -->
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker</artifactId>
<version>2.1.10</version>
</dependency>
<!-- The Type Annotations compiler. Uncomment if using Java 7 or annotations in comments. -->
<!-- <dependency>
<groupId>org.checkerframework</groupId>
<artifactId>compiler</artifactId>
<version>2.1.10</version>
</dependency> -->
<!-- The annotated JDK to use (change to jdk7 if using Java 7). -->
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>jdk8</artifactId>
<version>2.1.10</version>
</dependency>
</dependencies>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<!-- Change source and target to 1.7 if using Java 7 -->
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<annotationProcessors>
<!-- Add all the checkers you want to enable here -->
<annotationProcessor>
org.checkerframework.checker.nullness.NullnessChecker
</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<!-- location of the annotated JDK, which comes from a Maven dependency -->
<arg>-Xbootclasspath/p:${annotatedJdk}</arg>
<!-- Uncomment the following line to use the type annotations compiler. -->
<arg>-J-Xbootclasspath/p:${typeAnnotationsJavac}</arg>
</compilerArgs>
</configuration>
</plugin>
package org.service ; import java.util.Map ; import java.util.List ; import java.util.Arrays ; import java.nio.file.Path ; import java.io.IOException ; import java.nio.file.Paths ; import java.nio.file.Files ; import static java.util.Comparator.comparing ; import static java.util.stream.Collectors.toList ; import static java.util.stream.Collectors.counting ; import static java.util.stream.Collectors.groupingBy ; /** * * @author ryahiaoui */ public class Counter { private static List<String> getTopNFrequentWords( Path path, int rank ) throws IOException { return Files.lines(path) .parallel() .flatMap( line -> Arrays.asList ( line.split("\\b")).stream() ) .collect( groupingBy( w-> w, counting() ) ) .entrySet() .stream() .sorted( comparing ( Map.Entry< String, Long>::getValue).reversed() ) .limit( rank ) .map( Map.Entry::getKey ) .collect( toList() ) ; } public static void main(String[] args) throws IOException { // Top 10 most frequent words String path = "/testFile.txt" ; List<String> mostFrequentWords = getTopNFrequentWords ( Paths.get(path), 10 ) ; System.out.println( " mostFrequentWords = " + mostFrequentWords ) ; } }
Resource /planes:
Verbes get:
post:
put:
patch:
delete:
Identifiant /planes/{id}:
get:
post:
put:
patch:
delete:
Résultat responses:
200:
body:
application/json:
example: |
{
"B-777" : "Hello World"
}
/songs:
description: Collection of available songs in Jukebox
get:
description: Get a list of songs based on the song title.
queryParameters:
songTitle:
description: "The title of the song to search "
required: true
minLength: 3
type: string
example: "Get L"
responses:
200:
body:
application/json:
example: |
"songs": [
{
"songId": "550e8400-e29b-41d4-a716-446655440000",
"songTitle": "Get Lucky"
},
{
"songId": "550e8400-e29b-41d4-a716-446655440111",
"songTitle": "Loose yourself to dance"
},
{
"songId": "550e8400-e29b-41d4-a716-446655440222",
"songTitle": "Gio sorgio by Moroder"
}
]
/{songId}:
description: Song entity
get:
description: Get the song with `songId = {songId}`
responses:
200:
body:
application/json:
example: |
{
"songId": "550e8400-e29b-41d4-a716-446655440000",
"songTitle": "Get Lucky",
"duration": "6:07",
"artist": {
"artistId": "110e8300-e32b-41d4-a716-664400445500"
"artistName": "Daft Punk",
"imageURL": "http://travelhymns.com/random-access-memories1.jpg"
},
"album": {
"albumId": "183100e3-0e2b-4404-a716-66104d440550",
"albumName": "Random Access Memories",
"imageURL": "http://upload.wikimedia.org/Random_Access_Memories.jpg"
}
}
404:
body:
application/json:
example: |
{"message": "Song not found"}
/file-content:
description: The file to be reproduced by the client
get:
description: Get the file content
responses:
200:
post:
post:
npm install -g api-designer
api-designer
docker build -t api-console .
docker run --name my-api-console_1 -p 9000:9000 -d api-console
http://localhost:9000/index.html?raml=apis/simple.raml
docker run --name my-api-console_1 -p 9000:9000 -d -v $(pwd)/raml-files:/data/dist/apis api-console
http://localhost:9000/index.html?raml=apis/planes.raml
http://localhost:9000/index.html?raml=apis/planes/api-plane.raml
raml2html -i simple.raml -o example.html
raml2html -i raml-files/planes/api-plane.raml -o api-plane-doc.html
osprey-mock-service -f simple.raml -p 8000 --cors
osprey-mock-service -f raml-files/planes/api-plane.raml -p 8000 --cors
abao simple.raml --server http://localhost:8000/v1
abao raml-files/planes/api-plane.raml --server http://localhost:8000/v1
raml-mockup simple.raml -p 5000 -w
raml-mockup raml-files/planes/api-plane.raml -p 5000 -w
----------------------------------------------------------------------
raml-mockup raml-files/planes/api-plane.raml -p 8000 -w
abao raml-files/planes/api-plane.raml --server http://localhost:8000
----------------------------------------------------------------------
<plugin>
<groupId>org.raml.plugins</groupId>
<artifactId>raml-jaxrs-maven-plugin</artifactId>
<version>1.3.4</version>
<configuration>
<!-- Use sourcePaths if you want to provide a single RAML file or a list of RAML files -->
<sourceDirectory>${basedir}/raml</sourceDirectory>
<!-- Optionally configure outputDirectory if you don't like the default value: -->
<!-- ${project.build.directory}/generated-sources/raml-JAX-RS -->
<!-- Replace with your package name -->
<basePackageName>com.acme.api</basePackageName>
<!-- Valid values: 1.1 2.0 -->
<jaxrsVersion>2.0</jaxrsVersion>
<useJsr303Annotations>false</useJsr303Annotations>
<!-- Valid values: jackson1 jackson2 gson none -->
<jsonMapper>jackson2</jsonMapper>
<removeOldOutput>true</removeOldOutput>
<!-- Optionally set extensions to a list of fully qualified names of classes
that implement org.raml.jaxrs.codegen.core.ext.GeneratorExtension -->
<!-- for example:
<extensions>
<param>com.abc.AuthorizationAnnotationExtension</param>
<param>com.abc.ParameterFilterExtension</param>
</extensions>
Custom annotator for json schema to pojo convertor
<customAnnotator>com.abc.MyCustomAnnotator</customAnnotator>
-->
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.raml.plugins</groupId>
<artifactId>jaxrs-raml-maven-plugin</artifactId>
<version>1.3.4</version>
<configuration>
<sourcePaths>
<param>${basedir}/src/main/java/contacts/Contact.java</param>
<param>${basedir}/src/main/java/contacts/ContactAttrs.java</param>
<param>${basedir}/src/main/java/contacts/Contacts.java</param>
</sourcePaths>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputFile>${project.build.directory}/generated-sources/jaxrs-raml/example.raml</outputFile>
<removeOldOutput>true</removeOldOutput>
</configuration>
<executions>
<execution>
<goals>
<goal>generate-raml</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
http://localhost:8080/raml-planes-api/resources/planes
http://localhost:8080/raml-planes-api/resources/planes/10
raml-php-generator raml-files/planes/api-plane.raml -o api-client-php
<?php
namespace SampleApi ;
require_once "vendor/autoload.php" ;
const TEMPLATE_REGEXP = '/{([^{}]+)}/' ;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Client as HttpClient ;
$options = [
'baseUri' => 'http://localhost:8080/raml-planes-api/resources/planes' ] ;
$client = new Client($options) ;
$planes = $client->resources->planes->get(null, $options)->getBody() ;
$planeByID = $client->resources->planes->id(10)->get(null, $options)->getBody() ;
echo "\n" ;
echo " All Planes : ----------------------------- " ;
echo "\n \n" ;
echo " $planes " ;
echo "\n \n" ;
echo " Plane by ID : ----------------------------- " ;
echo "\n \n " ;
echo " $planeByID " ;
echo "\n \n" ;
echo " ------------------------------------------ " ;
?>
php ramlMerge.php raml-files/planes/api-plane.raml > api-plane-full.raml
* Swagger
- Pros: Heavily adopted, large community of users and supporters, support multiple languages
- Cons: Lacks advanced constructs for metadata
* RAML
- Pros: Supports advanced constructs, decent adoption, human readable format, high industry backing
- Cons: Lacks code-level tooling, still unproven long-term