Skip to content

Commit f376870

Browse files
committed
initial commit
1 parent 6bc0c5e commit f376870

File tree

356 files changed

+53343
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+53343
-0
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

Tavis.OpenApi.sln

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.10
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApi", "src\OpenApi\OpenApi.csproj", "{A8E50143-69B2-472A-9D45-3F9A05D13202}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenApiTests", "src\OpenApiTests\OpenApiTests.csproj", "{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4AEDAD90-F854-4940-BFEE-6374CC92CAB0}"
11+
ProjectSection(SolutionItems) = preProject
12+
License.txt = License.txt
13+
readme.md = readme.md
14+
ReleaseNotes.md = ReleaseNotes.md
15+
EndProjectSection
16+
EndProject
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenApiWorkbench", "src\OpenApiWorkbench\OpenApiWorkbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}"
18+
EndProject
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenApiWebApp", "src\OpenApiWebApp\OpenApiWebApp.csproj", "{FAA05247-2640-459A-A1CE-0D66F21EE2AE}"
20+
EndProject
21+
Global
22+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
23+
Debug|Any CPU = Debug|Any CPU
24+
Release|Any CPU = Release|Any CPU
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{FAA05247-2640-459A-A1CE-0D66F21EE2AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{FAA05247-2640-459A-A1CE-0D66F21EE2AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{FAA05247-2640-459A-A1CE-0D66F21EE2AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{FAA05247-2640-459A-A1CE-0D66F21EE2AE}.Release|Any CPU.Build.0 = Release|Any CPU
43+
EndGlobalSection
44+
GlobalSection(SolutionProperties) = preSolution
45+
HideSolutionNode = FALSE
46+
EndGlobalSection
47+
GlobalSection(ExtensibilityGlobals) = postSolution
48+
SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565}
49+
EndGlobalSection
50+
EndGlobal

Todo.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ToDo List
2+
3+
## Approach
4+
5+
- [DONE] Never throw an exception from the parser, just add to the errors collection, and try and keep going
6+
- ..or provide a client parameter (NeverThrow, ThrowIfErrors, ThrowOnFirst)
7+
- [DONE] Load components first, or JIT load referenced items
8+
- Started. Add validation to model classes, throw exception as normal. Allow parser to catch exception and add to ParseErrors collection
9+
10+
## Organization
11+
12+
- [DONE] Move parse field dictionaries out of model classes (Still not convinced about this)
13+
- [DONE] Move errors collection to parsing context object
14+
15+
## Missing features
16+
17+
- parse V2 OpenAPI (Need high level understanding of how this is going to work)
18+
- [DONE] need tests to show $ref is working.
19+
20+
## Nice to have
21+
22+
- Add extension parsers

build.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SET PROJ=%~dp0src\OpenApi\OpenApi.csproj
2+
msbuild %PROJ% /t:restore /p:Configuration=Release
3+
msbuild %PROJ% /t:build /p:Configuration=Release
4+
msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts

fixtures/TestScenarios.http

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# OpenAPI Test cases
2+
3+
### Simplest thing ever
4+
POST http://localhost:50380/parser HTTP/1.1
5+
Content-Type: application/json
6+
7+
{
8+
"openapi": "3.0.0",
9+
"info" : {
10+
"title": "This is my API",
11+
"version": "1.0.0"
12+
},
13+
"paths" : {}
14+
}
15+
16+
17+
### Simplest thing ever
18+
POST http://localhost:50380/parser HTTP/1.1
19+
Content-Type: application/json
20+
21+
{
22+
"swagger": "2.0",
23+
"info": {
24+
"version": "1.0.0",
25+
"title": "Swagger Petstore",
26+
"contact": {
27+
"name": "Swagger API Team",
28+
"url": "http://swagger.io"
29+
},
30+
"license": {
31+
"name": "Creative Commons 4.0 International",
32+
"url": "http://creativecommons.org/licenses/by/4.0/"
33+
}
34+
},
35+
"host": "petstore.swagger.io",
36+
"basePath": "/api",
37+
"schemes": [
38+
"http"
39+
],
40+
"paths": {
41+
"/pets": {
42+
"get": {
43+
"tags": [ "Pet Operations" ],
44+
"summary": "finds pets in the system",
45+
"responses": {
46+
"200": {
47+
"description": "pet response",
48+
"schema": {
49+
"type": "array",
50+
"items": {
51+
"$ref": "#/definitions/Pet"
52+
}
53+
},
54+
"headers": {
55+
"x-expires": {
56+
"type": "string"
57+
}
58+
}
59+
},
60+
"default": {
61+
"description": "unexpected error",
62+
"schema": {
63+
"$ref": "#/definitions/Error"
64+
}
65+
}
66+
}
67+
}
68+
}
69+
},
70+
"definitions": {
71+
"Pet": {
72+
"type": "object",
73+
"required": [
74+
"id",
75+
"name"
76+
],
77+
"properties": {
78+
"id": {
79+
"type": "integer",
80+
"format": "int64"
81+
},
82+
"name": {
83+
"type": "string"
84+
},
85+
"tag": {
86+
"type": "string"
87+
}
88+
}
89+
},
90+
"Error": {
91+
"type": "object",
92+
"required": [
93+
"code",
94+
"message"
95+
],
96+
"properties": {
97+
"code": {
98+
"type": "integer",
99+
"format": "int32"
100+
},
101+
"message": {
102+
"type": "string"
103+
}
104+
}
105+
}
106+
}
107+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# All-in-one Static Hello World Sample
2+
3+
This sample project provides an all-one-one package demo for the Hello World sample described in the [wiki](https://github.com/swagger-api/swagger-spec/wiki/Hello-World-Sample).
4+
5+
## Requirements
6+
7+
This samples requires Java 5 or above and [Maven](http://maven.apache.org) installed.
8+
9+
## Run the sample
10+
11+
In your favorite command-line, run:
12+
13+
```
14+
mvn jetty:run
15+
```
16+
17+
Then in your favorite web browser, open:
18+
```
19+
http://localhost:8000
20+
```
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>io.swagger</groupId>
5+
<artifactId>swagger-demo</artifactId>
6+
<packaging>jar</packaging>
7+
<name>swagger-demo</name>
8+
<version>1.0.1-SNAPSHOT</version>
9+
<prerequisites>
10+
<maven>2.2.0</maven>
11+
</prerequisites>
12+
13+
<build>
14+
<sourceDirectory>src/main/scala</sourceDirectory>
15+
<testSourceDirectory>src/test/scala</testSourceDirectory>
16+
<plugins>
17+
<plugin>
18+
<groupId>net.alchim31.maven</groupId>
19+
<artifactId>scala-maven-plugin</artifactId>
20+
<version>${maven-plugin.version}</version>
21+
<executions>
22+
<execution>
23+
<goals>
24+
<goal>compile</goal>
25+
<goal>testCompile</goal>
26+
</goals>
27+
</execution>
28+
</executions>
29+
<configuration>
30+
<jvmArgs>
31+
<jvmArg>-Xms64m</jvmArg>
32+
<jvmArg>-Xmx1024m</jvmArg>
33+
</jvmArgs>
34+
</configuration>
35+
</plugin>
36+
<plugin>
37+
<artifactId>maven-surefire-plugin</artifactId>
38+
<configuration>
39+
<forkMode>once</forkMode>
40+
<useFile>false</useFile>
41+
</configuration>
42+
</plugin>
43+
<plugin>
44+
<artifactId>maven-dependency-plugin</artifactId>
45+
<executions>
46+
<execution>
47+
<phase>package</phase>
48+
<goals>
49+
<goal>copy-dependencies</goal>
50+
</goals>
51+
<configuration>
52+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.mortbay.jetty</groupId>
59+
<artifactId>jetty-maven-plugin</artifactId>
60+
<version>${jetty-version}</version>
61+
<configuration>
62+
<webAppConfig>
63+
<contextPath>/</contextPath>
64+
</webAppConfig>
65+
<connectors>
66+
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
67+
<port>8000</port>
68+
<maxIdleTime>60000</maxIdleTime>
69+
<confidentialPort>8443</confidentialPort>
70+
</connector>
71+
</connectors>
72+
</configuration>
73+
<executions>
74+
<execution>
75+
<id>start-jetty</id>
76+
<phase>pre-integration-test</phase>
77+
<goals>
78+
<goal>run</goal>
79+
</goals>
80+
<configuration>
81+
<scanIntervalSeconds>0</scanIntervalSeconds>
82+
<daemon>true</daemon>
83+
</configuration>
84+
</execution>
85+
<execution>
86+
<id>stop-jetty</id>
87+
<phase>post-integration-test</phase>
88+
<goals>
89+
<goal>stop</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
<repositories>
97+
<repository>
98+
<id>sonatype-snapshots</id>
99+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
100+
</repository>
101+
<repository>
102+
<id>sonatype-releases</id>
103+
<url>https://oss.sonatype.org/content/repositories/releases</url>
104+
</repository>
105+
</repositories>
106+
<properties>
107+
<maven-plugin.version>3.1.0</maven-plugin.version>
108+
<jetty-version>7.6.0.v20120127</jetty-version>
109+
</properties>
110+
</project>
111+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"swaggerVersion": "1.2",
3+
"apis": [
4+
{
5+
"path": "http://localhost:8000/listings/greetings",
6+
"description": "Generating greetings in our application."
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)