Skip to content

Commit 9cfe04c

Browse files
committed
add rest_ejem10 example using HTTPS
1 parent f4e09a5 commit 9cfe04c

File tree

14 files changed

+4965
-0
lines changed

14 files changed

+4965
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Comando para generar la doc (asumiendo estar en la raíz del proyecto) (si estás en Windows recomendable ejecutar el comando en Git Bash, ya que no funciona en Powershell):
2+
3+
```sh
4+
mvn verify -Djavax.net.ssl.trustStore=src/main/resources/keystore.jks -Djavax.net.ssl.trustStorePassword=password
5+
```
6+
7+
Nota: Al generar la keystore.jks con keytool, el CN debe ser localhost, por ejemplo:
8+
9+
```sh
10+
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
11+
```
12+
```
13+
Enter the distinguished name. Provide a single dot (.) to leave a sub-component empty or press ENTER to use the default value in braces.
14+
What is your first and last name?
15+
[Unknown]: localhost
16+
What is the name of your organizational unit?
17+
[Unknown]: URJC
18+
What is the name of your organization?
19+
[Unknown]: URJC
20+
What is the name of your City or Locality?
21+
[Unknown]: Madrid
22+
What is the name of your State or Province?
23+
[Unknown]: Madrid
24+
What is the two-letter country code for this unit?
25+
[Unknown]: ES
26+
Is CN=localhost, OU=URJC, O=URJC, L=Madrid, ST=Madrid, C=ES correct?
27+
[no]: yes
28+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.2.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3f9384ad8db3d6c6149c8750bb253f3030e39806df96cfd2953531b591760e88

parte_2/tema_2.3_rest/rest_ejem10 (Spring 3 y HTTPS)/api-docs/api-docs.html

+4,484
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
openapi: 3.0.1
2+
info:
3+
title: OpenAPI definition
4+
version: v0
5+
servers:
6+
- url: https://localhost:8443
7+
description: Generated server url
8+
paths:
9+
/posts/{id}:
10+
get:
11+
tags:
12+
- post-controller
13+
operationId: getPost
14+
parameters:
15+
- name: id
16+
in: path
17+
required: true
18+
schema:
19+
type: integer
20+
format: int64
21+
responses:
22+
"200":
23+
description: OK
24+
content:
25+
'*/*':
26+
schema:
27+
$ref: '#/components/schemas/Post'
28+
put:
29+
tags:
30+
- post-controller
31+
operationId: replacePost
32+
parameters:
33+
- name: id
34+
in: path
35+
required: true
36+
schema:
37+
type: integer
38+
format: int64
39+
requestBody:
40+
content:
41+
application/json:
42+
schema:
43+
$ref: '#/components/schemas/Post'
44+
required: true
45+
responses:
46+
"200":
47+
description: OK
48+
content:
49+
'*/*':
50+
schema:
51+
$ref: '#/components/schemas/Post'
52+
delete:
53+
tags:
54+
- post-controller
55+
operationId: deletePost
56+
parameters:
57+
- name: id
58+
in: path
59+
required: true
60+
schema:
61+
type: integer
62+
format: int64
63+
responses:
64+
"200":
65+
description: OK
66+
content:
67+
'*/*':
68+
schema:
69+
$ref: '#/components/schemas/Post'
70+
/posts/:
71+
get:
72+
tags:
73+
- post-controller
74+
operationId: getPosts
75+
responses:
76+
"200":
77+
description: OK
78+
content:
79+
'*/*':
80+
schema:
81+
type: array
82+
items:
83+
$ref: '#/components/schemas/Post'
84+
post:
85+
tags:
86+
- post-controller
87+
operationId: createPost
88+
requestBody:
89+
content:
90+
application/json:
91+
schema:
92+
$ref: '#/components/schemas/Post'
93+
required: true
94+
responses:
95+
"200":
96+
description: OK
97+
content:
98+
'*/*':
99+
schema:
100+
$ref: '#/components/schemas/Post'
101+
components:
102+
schemas:
103+
Post:
104+
type: object
105+
properties:
106+
id:
107+
type: integer
108+
format: int64
109+
user:
110+
type: string
111+
title:
112+
type: string
113+
text:
114+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>es.codeurjc</groupId>
8+
<artifactId>rest_ejem10</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<parent>
13+
<groupId>org.springframework.boot</groupId>
14+
<artifactId>spring-boot-starter-parent</artifactId>
15+
<version>3.2.1</version>
16+
<relativePath />
17+
</parent>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<java.version>17</java.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springdoc</groupId>
31+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
32+
<version>2.3.0</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-devtools</artifactId>
37+
</dependency>
38+
</dependencies>
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-maven-plugin</artifactId>
44+
<executions>
45+
<execution>
46+
<id>pre-integration-test</id>
47+
<goals>
48+
<goal>start</goal>
49+
</goals>
50+
</execution>
51+
<execution>
52+
<id>post-integration-test</id>
53+
<goals>
54+
<goal>stop</goal>
55+
</goals>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
<plugin>
60+
<groupId>org.springdoc</groupId>
61+
<artifactId>springdoc-openapi-maven-plugin</artifactId>
62+
<version>1.4</version>
63+
<executions>
64+
<execution>
65+
<phase>integration-test</phase>
66+
<goals>
67+
<goal>generate</goal>
68+
</goals>
69+
</execution>
70+
</executions>
71+
<configuration>
72+
<apiDocsUrl>https://localhost:8443/v3/api-docs.yaml</apiDocsUrl>
73+
<outputFileName>api-docs.yaml</outputFileName>
74+
<outputDir>${project.basedir}/api-docs</outputDir>
75+
</configuration>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.openapitools</groupId>
79+
<artifactId>openapi-generator-maven-plugin</artifactId>
80+
<version>7.2.0</version>
81+
<executions>
82+
<execution>
83+
<phase>integration-test</phase>
84+
<goals>
85+
<goal>generate</goal>
86+
</goals>
87+
<configuration>
88+
<generatorName>html2</generatorName>
89+
<inputSpec>${project.basedir}/api-docs/api-docs.yaml</inputSpec>
90+
<output>${project.basedir}/api-docs/</output>
91+
</configuration>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>com.coderplus.maven.plugins</groupId>
97+
<artifactId>copy-rename-maven-plugin</artifactId>
98+
<version>1.0</version>
99+
<executions>
100+
<execution>
101+
<phase>integration-test</phase>
102+
<id>copy-file</id>
103+
<goals>
104+
<goal>rename</goal>
105+
</goals>
106+
<configuration>
107+
<sourceFile>api-docs/index.html</sourceFile>
108+
<destinationFile>api-docs/api-docs.html</destinationFile>
109+
</configuration>
110+
</execution>
111+
</executions>
112+
</plugin>
113+
</plugins>
114+
</build>
115+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package es.codeurjc.board;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package es.codeurjc.board;
2+
3+
public class Post {
4+
5+
private Long id;
6+
private String user;
7+
private String title;
8+
private String text;
9+
10+
public Post() {
11+
12+
}
13+
14+
public Post(String user, String title, String text) {
15+
super();
16+
this.user = user;
17+
this.title = title;
18+
this.text = text;
19+
}
20+
21+
public Long getId() {
22+
return id;
23+
}
24+
25+
public void setId(long id) {
26+
this.id = id;
27+
}
28+
29+
public String getUser() {
30+
return user;
31+
}
32+
33+
public void setUser(String user) {
34+
this.user = user;
35+
}
36+
37+
public String getTitle() {
38+
return title;
39+
}
40+
41+
public void setTitle(String title) {
42+
this.title = title;
43+
}
44+
45+
public String getText() {
46+
return text;
47+
}
48+
49+
public void setText(String text) {
50+
this.text = text;
51+
}
52+
53+
@Override
54+
public String toString() {
55+
return "Post [id="+id+", user=" + user + ", title=" + title + ", text=" + text + "]";
56+
}
57+
58+
}

0 commit comments

Comments
 (0)