Skip to content

Commit

Permalink
fixes #154 splite openapi-meta to move specification parser to openap…
Browse files Browse the repository at this point in the history
…i-helper (#155)
  • Loading branch information
stevehu committed Dec 15, 2020
1 parent 5ecac94 commit efb2529
Show file tree
Hide file tree
Showing 13 changed files with 1,277 additions and 1 deletion.
62 changes: 62 additions & 0 deletions openapi-helper/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!--
~ Copyright (c) 2016 Network New Technologies Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.networknt</groupId>
<artifactId>light-rest-4j</artifactId>
<version>2.0.22-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>openapi-helper</artifactId>
<packaging>jar</packaging>
<description>An OpenAPI Specification 3.0 helper to cache the spec for other component to use</description>

<dependencies>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-overlay</artifactId>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>openapi-parser</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Binary file not shown.
293 changes: 293 additions & 0 deletions openapi-helper/src/test/resources/config/openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"security": [
{
"petstore_auth": [
"read:pets"
]
}
],
"responses": {
"200": {
"description": "An paged array of pets",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
},
"example": [
{
"id": 1,
"name": "catten",
"tag": "cat"
},
{
"id": 2,
"name": "doggy",
"tag": "dog"
}
]
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"requestBody": {
"description": "Pet to add to the store",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"tags": [
"pets"
],
"security": [
{
"petstore_auth": [
"read:pets",
"write:pets"
]
}
],
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": [
"pets"
],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to retrieve",
"schema": {
"type": "string"
}
}
],
"security": [
{
"petstore_auth": [
"read:pets"
]
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
},
"example": {
"id": 1,
"name": "Jessica Right",
"tag": "pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"delete": {
"summary": "Delete a specific pet",
"operationId": "deletePetById",
"tags": [
"pets"
],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to delete",
"schema": {
"type": "string"
}
},
{
"name": "key",
"in": "header",
"required": true,
"description": "The key header",
"schema": {
"type": "string"
}
}
],
"security": [
{
"petstore_auth": [
"write:pets"
]
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"petstore_auth": {
"type": "oauth2",
"description": "This API uses OAuth 2 with the client credential grant flow.",
"flows": {
"clientCredentials": {
"tokenUrl": "https://localhost:6882/token",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
}
},
"schemas": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
Loading

0 comments on commit efb2529

Please sign in to comment.