Skip to content

Commit ec6adc6

Browse files
Merge pull request #18553 from programenth/swagger-tag
Adding Swagger YML changes | BAEL-9296
2 parents 76d6973 + 42eeeda commit ec6adc6

File tree

4 files changed

+86
-0
lines changed

4 files changed

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

0 commit comments

Comments
 (0)