Skip to content

Commit 3fbb310

Browse files
authored
Adding Swagger YML changes
1 parent 67f015d commit 3fbb310

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring.application.name=demo
2+
springdoc.api-docs.enabled=true
3+
springdoc.api-docs.path=/v3/api-docs
4+
springdoc.api-docs.resolve-schema-properties=false
5+
springdoc.swagger-ui.url=/openapi.yml
6+
springdoc.swagger-ui.path=/swagger-ui.html
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type: object
2+
properties:
3+
id:
4+
type: integer
5+
format: int64
6+
name:
7+
type: string
8+
rollNo:
9+
type: string
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Student API
4+
description: Following documentation explain the API's supported by the [student server](http://localhost:8080).
5+
version: 1.1.9
6+
7+
servers:
8+
- url: http://localhost:8080/v1
9+
description: Prod server
10+
variables:
11+
region:
12+
default: us-west
13+
enum:
14+
- us-west
15+
- us-east
16+
- url: http://localhost:8080/test
17+
description: Test server
18+
19+
paths:
20+
/students:
21+
get:
22+
tags:
23+
- Students
24+
summary: Returns all the students.
25+
description: Following path gives all the data related to students
26+
responses:
27+
"200":
28+
description: A JSON array of student objects
29+
content:
30+
application/json:
31+
schema:
32+
type: array
33+
items:
34+
$ref: './components/schemas/Student.yml'
35+
36+
/students/{id}:
37+
get:
38+
tags:
39+
- Students
40+
summary: Gets a student by ID.
41+
description: >
42+
Gives the details of specific student based on **ID**
43+
operationId: getStudentById
44+
parameters:
45+
- name: id
46+
in: path
47+
description: Student ID
48+
required: true
49+
schema:
50+
type: integer
51+
format: int64
52+
responses:
53+
"200":
54+
description: Successful operation
55+
content:
56+
application/json:
57+
schema:
58+
$ref: './components/schemas/Student.yml'
59+
externalDocs:
60+
description: Learn more about student operations provided by this API.
61+
url: http://localhost:8080/swagger-ui/index.html
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.swaggeryml;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.builder.SpringApplicationBuilder;
6+
7+
@SpringBootApplication
8+
public class SwaggerymlApplication {
9+
10+
public static void main(String[] args) {
11+
SpringApplication.run(SwaggerymlApplication.class, args);
12+
// new SpringApplicationBuilder(SwaggerymlApplication.class)
13+
// .properties("spring.config.name=application-yml")
14+
// .run(args);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)