Skip to content

Commit

Permalink
Merge pull request #12 from manuelmerkel/rule/#10/lowercase
Browse files Browse the repository at this point in the history
Rule/#10/lowercase and Rule/#13/hyphens

Former-commit-id: cc839fb99cf47229aad7e59205544934a3211421 [formerly 380c5a2]
Former-commit-id: 4b4e840ca878af4888a9eea404be310af3f1575e
Former-commit-id: 77647d512bcf7466d76eb050ff59bcbda0d647e2
  • Loading branch information
manuelmerkel authored Aug 16, 2022
2 parents ab8bac8 + 9e403b6 commit 566f794
Show file tree
Hide file tree
Showing 18 changed files with 7,864 additions and 96 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
.gradle
.idea
./rest-studentproject/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Lowercase letters should be preferred in URI paths

## Category

URIs

## Importance, severity, difficulty

* Importance: high
* Severity: error
* Difficulty to implement the rule: easy

## Quality Attribute

* Maintainability

## Rule Description

Description from Massé [1].

To make your URIs easy for people to scan and interpret, use the hyphen (-) character
to improve the readability of names in long path segments. Anywhere you would use
a space or hyphen in English, you should use a hyphen in a URI.

## Implemented

* Yes

## Implementation Details (Issue #13)

* Static implementation
* Check if a path segment can be reduced to more than one word. If yes and the path segment does not contain (-) hyphens, there is a violation
* Give the hint to use hyphens to separate words in a path segment

### What is checked:
* extract path segments from path using "/" as delimiter
* based on an English dictionary, the extracted path is checked for substrings. If one or more substrings are found, there is a violation of the rule
* pathSegment can be camelCase, kebabCase, snakeCase, all lowercase, all uppercase, or just a mixture of these

### What is not checked:
* presence of invalid delimiters
* check of dynamic parameters

### Future work

* None


## Source

[1] https://www.oreilly.com/library/view/rest-api-design/9781449317904/
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Lowercase letters should be preferred in URI paths

## Category

URIs

## Importance, severity, difficulty

* Importance: high
* Severity: error
* Difficulty to implement the rule: easy

## Quality Attribute

* Maintainability

## Rule Description

Description from Massé [1].

When convenient, lowercase letters are preferred in URI paths since capital letters can
sometimes cause problems. RFC 3986 defines URIs as case-sensitive except for the
scheme and host components.

## Implemented

* Yes

## Implementation Details (Issue #10)

* Static implementation
* Check path if it contains an uppercase letter, if so give a warning
* Give the hint to use lowercase letters instead of uppercase

### What is checked:
* check if the path contains an uppercase letter
* check if the path is empty or there are no paths

### What is not checked:
* presence of invalid delimiters
* check of dynamic parameters

### Future work

* None

## Source

[1] https://www.oreilly.com/library/view/rest-api-design/9781449317904/
190 changes: 119 additions & 71 deletions docs/Studiendesign/evaluation/gold-standard/static-openAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,81 +50,129 @@ paths:
"404":
description: "Not Found"
"/Pets":
get:
tag: "URI Rules"
description: "Get Pets"
response:
"200":
description: "A list of pets"
"400":
description: The specified user ID is invalid (not a number).
"401":
description: Unauthorized
"404":
description: A user with the specified ID was not found.
summary: "A list of pets",
tags:
"pets"
get:
tag: "URI Rules"
description: "Get Pets. Violations: Lowercase letters should be preferred in URI paths. Pets should be pets."
response:
"200":
description: "A list of pets"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found.""
summary: "A list of pets"
tags:
"pets"

"/pets/{petName}/LocationsStates":
get:
tag: "URI Rules"
description: "Get Pet Locations States",
response:
"200":
description: "A list of locations states given a pet name"
"400":
description: The specified user ID is invalid (not a number).
"401":
description: Unauthorized
"404":
description: A user with the specified ID was not found.
summary: "A list of locations states given a pet name",
tags:
"pets"
"/pets/{petName}/LocationsStates":
get:
tag: "URI Rules"
description: "Get Pet Locations States. Violations: Lowercase letters should be preferred in URI paths. LocationsStates should be locationsstates"
response:
"200":
description: "A list of locations states given a pet name"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "A list of locations states given a pet name"
tags:
"pets"

"/pets/{petName}/locations/{locationName}/CITY":
get:
tag: "URI Rules"
description: "Get Pet Location City"
response:
"200":
description: "City where a pet is located"
"400":
description: The specified user ID is invalid (not a number).
"401":
description: Unauthorized
"404":
description: A user with the specified ID was not found.
summary: "City where a pet is located"
tags:
"pets"
"/pets/{petName}/locations/{locationName}/CITY":
get:
tag: "URI Rules"
description: "Get Pet Location City. Violations: Lowercase letters should be preferred in URI paths. CITY should be city."
response:
"200":
description: "City where a pet is located"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "City where a pet is located"
tags:
"pets"

"/pets/{petName}/addLocation":
get:
tag: "URI Rules"
description: "Add a new location to a pet"
requestBody:
content:
application/json:
examples:
basic:
"$ref": "#/components/examples/post-createNotificationConfiguration-basic"
schema:
$ref: "#/components/schemas/CreateNotificationConfigurationRequest"

response:
"200":
description: "Country where a pet is located"
"400":
description: The specified user ID is invalid (not a number).
"401":
description: Unauthorized
"404":
description: A user with the specified ID was not found.
summary: "Country where a pet is located"
"/pets/{petName}/addLocation":
get:
tag: "URI Rules"
description: "Add a new location to a pet. Violations: Lowercase letters should be preferred in URI paths. Location should be location"
requestBody:
content:
application/json:
examples:
basic:
"$ref": "#/components/examples/post-createNotificationConfiguration-basic"
schema:
$ref: "#/components/schemas/CreateNotificationConfigurationRequest"

response:
"200":
description: "Country where a pet is located"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "Country where a pet is located"
tags:
"pets"
"/bigPets":
get:
tag: "URI Rules"
description: "Violations: LHyphens (-) should be used to improve the readability of URIs. bigPets should be written as big-pets."
response:
"200":
description: "Big cats"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "List of big cats"
tags:
"pets"
"/small.Pets":
get:
tag: "URI Rules"
description: "Violations: LHyphens (-) should be used to improve the readability of URIs. small.Pets should be written as small-pets."
response:
"200":
description: "Small cats"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "List of small cats"
tags:
"pets"
"pets"
"/MediumSizePets":
get:
tag: "URI Rules"
description: "Violations: LHyphens (-) should be used to improve the readability of URIs. MediumSizePets should be written as medium-size-pets."
response:
"200":
description: "Small cats"
"400":
description: "The specified user ID is invalid (not a number)."
"401":
description: "Unauthorized"
"404":
description: "A user with the specified ID was not found."
summary: "List of small cats"
tags:
"pets"
components:
# Define all components here
securitySchemes:
Expand Down
3 changes: 2 additions & 1 deletion rest-studentproject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ dependencies {
runtimeOnly("ch.qos.logback:logback-classic")
implementation("io.micronaut:micronaut-validation")
implementation("io.swagger.parser.v3:swagger-parser-v3:2.1.1")
implementation 'io.swagger.parser.v3:swagger-parser:2.1.1'
implementation ("io.swagger.parser.v3:swagger-parser:2.1.1")
testImplementation("io.micronaut:micronaut-http-client")
implementation("org.apache.directory.studio:org.apache.commons.io:2.4")

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8fd15e2358d7c283be8e0b9a3ba9b9f1b677bcfb
Loading

0 comments on commit 566f794

Please sign in to comment.