Skip to content
Snippets Groups Projects
Commit 8f5368d4 authored by Jueun Park's avatar Jueun Park
Browse files

edited test fully

parent e3d7a47b
No related branches found
No related tags found
1 merge request!1Tests/openapi generator
Showing
with 72 additions and 1144 deletions
...@@ -34,7 +34,7 @@ CallbackTuple ::= <Key> O:CallbackOb; ...@@ -34,7 +34,7 @@ CallbackTuple ::= <Key> O:CallbackOb;
PathItemTuple ::= <Key> O:PathItemOb; PathItemTuple ::= <Key> O:PathItemOb;
//Paths Object //Paths Object
PathsObject ::= <Ref> P:PathItemOb; PathsObject ::= <Ref> P:PathItemOb Ex:Extension*;
//Path Item Object //Path Item Object
abstract PathItemOb; abstract PathItemOb;
......
...@@ -24,8 +24,16 @@ public static OpenAPIObject OpenAPIObject.parseOpenAPI(OpenAPI api) { ...@@ -24,8 +24,16 @@ public static OpenAPIObject OpenAPIObject.parseOpenAPI(OpenAPI api) {
if (api.getInfo() != null) if (api.getInfo() != null)
openapi.setI(InfoObject.parseInfo(api.getInfo())); openapi.setI(InfoObject.parseInfo(api.getInfo()));
if (api.getPaths() != null) { if (api.getPaths() != null) {
for (String key : api.getPaths().keySet()) for (String key : api.getPaths().keySet()) {
openapi.addP(new PathsObject(key, PathItemObject.parsePath(api.getPaths().get(key)))); PathsObject path = new PathsObject();
path.setRef(key);
path.setP(PathItemObject.parsePath(api.getPaths().get(key)));
if (api.getPaths().getExtensions() != null) {
for (String pKey : api.getPaths().getExtensions().keySet())
path.addEx(new Extension(pKey, api.getPaths().getExtensions().get(pKey)));
}
openapi.addP(path);
}
} }
if (api.getServers() != null) { if (api.getServers() != null) {
for (io.swagger.v3.oas.models.servers.Server s : api.getServers()) for (io.swagger.v3.oas.models.servers.Server s : api.getServers())
...@@ -379,6 +387,8 @@ public static ParameterOb ParameterOb.parseParameter(Parameter parameter) { ...@@ -379,6 +387,8 @@ public static ParameterOb ParameterOb.parseParameter(Parameter parameter) {
parameterObject.setExplode(parameter.getExplode()); parameterObject.setExplode(parameter.getExplode());
if (parameter.getAllowReserved() != null) if (parameter.getAllowReserved() != null)
parameterObject.setAllowReserved(parameter.getAllowReserved()); parameterObject.setAllowReserved(parameter.getAllowReserved());
if (parameter.getAllowEmptyValue() != null)
parameterObject.setAllowEmptyValue(parameter.getAllowEmptyValue());
if (parameter.getSchema() != null) if (parameter.getSchema() != null)
parameterObject.setSchema(SchemaOb.parseSchema(parameter.getSchema())); parameterObject.setSchema(SchemaOb.parseSchema(parameter.getSchema()));
if (parameter.getExample() != null) if (parameter.getExample() != null)
...@@ -508,10 +518,11 @@ public static ResponseOb ResponseOb.parseResponse(ApiResponse response) { ...@@ -508,10 +518,11 @@ public static ResponseOb ResponseOb.parseResponse(ApiResponse response) {
responseObject.addL(new LinkTuple(key, LinkOb.parseLink(response.getLinks().get(key)))); responseObject.addL(new LinkTuple(key, LinkOb.parseLink(response.getLinks().get(key))));
} }
if (response.getExtensions() != null) { if (response.getExtensions() != null) {
for (String key : response.getExtensions().keySet()) for (String key : response.getExtensions().keySet()) {
responseObject.addEx(new Extension(key, response.getExtensions().get(key))); responseObject.addEx(new Extension(key, response.getExtensions().get(key)));
} }
} }
}
return responseObject; return responseObject;
} }
...@@ -745,11 +756,9 @@ public static SchemaOb SchemaOb.parseSchema (Schema<?> schema) { ...@@ -745,11 +756,9 @@ public static SchemaOb SchemaOb.parseSchema (Schema<?> schema) {
if (schema.getPattern() != null) if (schema.getPattern() != null)
schemaObject.setPattern(schema.getPattern()); schemaObject.setPattern(schema.getPattern());
if (schema.getProperties() != null) { if (schema.getProperties() != null) {
for (String key : schema.getProperties().keySet()) { for (String key : schema.getProperties().keySet())
PropertyItem propertyItem = new PropertyItem();
schemaObject.addP(new PropertyItem(key, parseSchema(schema.getProperties().get(key)))); schemaObject.addP(new PropertyItem(key, parseSchema(schema.getProperties().get(key))));
} }
}
if (schema.getRequired() != null) { if (schema.getRequired() != null) {
for (String s : schema.getRequired()) { for (String s : schema.getRequired()) {
RequiredField requiredField = new RequiredField(); RequiredField requiredField = new RequiredField();
......
...@@ -15,14 +15,16 @@ aspect ReverseParser{ ...@@ -15,14 +15,16 @@ aspect ReverseParser{
servers.add(ServerObject.reverseServer(s)); servers.add(ServerObject.reverseServer(s));
api.setServers(servers); api.setServers(servers);
} }
if (openapi.getNumP() != 0) {
Paths paths = new Paths(); Paths paths = new Paths();
for (PathsObject p : openapi.getPList()) { for (PathsObject p : openapi.getPList()) {
if (p.getP() instanceof PathItemObject) if (p.getP() instanceof PathItemObject)
paths.addPathItem(p.getRef(), p.getP().reversePath(p.getP())); paths.addPathItem(p.getRef(), p.getP().reversePath(p.getP()));
if (p.getNumEx() != 0) {
for (Extension e : p.getExList())
paths.addExtension(e.getKey(), e.getValue());
} }
api.setPaths(paths);
} }
api.setPaths(paths);
if (openapi.getC() != null) if (openapi.getC() != null)
api.setComponents(ComponentsObject.reverseComponents(openapi.getC())); api.setComponents(ComponentsObject.reverseComponents(openapi.getC()));
if (openapi.getNumSr() != 0) { if (openapi.getNumSr() != 0) {
...@@ -56,7 +58,7 @@ aspect ReverseParser{ ...@@ -56,7 +58,7 @@ aspect ReverseParser{
public static io.swagger.v3.oas.models.info.Info InfoObject.reverseInfo(InfoObject infoObject){ public static io.swagger.v3.oas.models.info.Info InfoObject.reverseInfo(InfoObject infoObject){
io.swagger.v3.oas.models.info.Info info = new io.swagger.v3.oas.models.info.Info(); io.swagger.v3.oas.models.info.Info info = new io.swagger.v3.oas.models.info.Info();
if (!infoObject.getTitle().isEmpty()) if (infoObject.getTitle() != null)
info.setTitle(infoObject.getTitle()); info.setTitle(infoObject.getTitle());
if (!infoObject.getVersion().isEmpty()) if (!infoObject.getVersion().isEmpty())
info.setVersion(infoObject.getVersion()); info.setVersion(infoObject.getVersion());
...@@ -391,9 +393,9 @@ aspect ReverseParser{ ...@@ -391,9 +393,9 @@ aspect ReverseParser{
io.swagger.v3.oas.models.parameters.Parameter parameter = new io.swagger.v3.oas.models.parameters.Parameter(); io.swagger.v3.oas.models.parameters.Parameter parameter = new io.swagger.v3.oas.models.parameters.Parameter();
ParameterObject p = (ParameterObject) parameterOb; ParameterObject p = (ParameterObject) parameterOb;
if (!p.getName().isEmpty()) if (p.getName() != null)
parameter.setName(p.getName()); parameter.setName(p.getName());
if (!p.getIn().isEmpty()) if (p.getIn() != null)
parameter.setIn(p.getIn()); parameter.setIn(p.getIn());
if (p.getRequired() != null) if (p.getRequired() != null)
parameter.setRequired(p.getRequired()); parameter.setRequired(p.getRequired());
...@@ -426,6 +428,8 @@ aspect ReverseParser{ ...@@ -426,6 +428,8 @@ aspect ReverseParser{
} }
if (p.getAllowReserved() != null) if (p.getAllowReserved() != null)
parameter.setAllowReserved(p.getAllowReserved()); parameter.setAllowReserved(p.getAllowReserved());
if (p.getAllowEmptyValue() != null)
parameter.setAllowEmptyValue(p.getAllowEmptyValue());
if (p.getExplode() != null) if (p.getExplode() != null)
parameter.setExplode(p.getExplode()); parameter.setExplode(p.getExplode());
if (p.getSchema() != null) if (p.getSchema() != null)
...@@ -471,16 +475,18 @@ aspect ReverseParser{ ...@@ -471,16 +475,18 @@ aspect ReverseParser{
RequestBody requestBody = new RequestBody(); RequestBody requestBody = new RequestBody();
RequestBodyObject r = (RequestBodyObject) requestBodyOb; RequestBodyObject r = (RequestBodyObject) requestBodyOb;
if (r.getNumC() != 0) {
io.swagger.v3.oas.models.media.Content contents = new Content(); io.swagger.v3.oas.models.media.Content contents = new Content();
for (ContentTuple t : r.getCList()) for (ContentTuple t : r.getCList())
contents.put(t.getKey(), MediaTypeObject.reverseMediaType(t.getM())); contents.put(t.getKey(), MediaTypeObject.reverseMediaType(t.getM()));
requestBody.setContent(contents); requestBody.setContent(contents);
}
if (!r.getDescription().isEmpty()) if (!r.getDescription().isEmpty())
requestBody.setDescription(r.getDescription()); requestBody.setDescription(r.getDescription());
if (r.getRequired() != null) if (r.getRequired() != null)
requestBody.setRequired(r.getRequired()); requestBody.setRequired(r.getRequired());
if (r.getNumEx() != 0){
for ( Extension e : r.getExList() )
requestBody.addExtension(e.getKey(), e.getValue());
}
return requestBody; return requestBody;
} }
...@@ -525,8 +531,20 @@ aspect ReverseParser{ ...@@ -525,8 +531,20 @@ aspect ReverseParser{
} }
encodingProperty.setHeaders(headers); encodingProperty.setHeaders(headers);
} }
//if (!encodingObject.getStyle().isEmpty()) switch (encodingObject.getStyle()) {
// encodingProperty.setStyle(Encoding.StyleEnum.valueOf()); case ("form") :
encodingProperty.setStyle(Encoding.StyleEnum.FORM);
break;
case ("spaceDelimited") :
encodingProperty.setStyle(Encoding.StyleEnum.SPACE_DELIMITED);
break;
case ("pipeDelimited") :
encodingProperty.setStyle(Encoding.StyleEnum.PIPE_DELIMITED);
break;
case ("deepObject") :
encodingProperty.setStyle(Encoding.StyleEnum.DEEP_OBJECT);
break;
}
if (encodingObject.getExplode() != null) if (encodingObject.getExplode() != null)
encodingProperty.setExplode(encodingObject.getExplode()); encodingProperty.setExplode(encodingObject.getExplode());
if (encodingObject.getNumEx() != 0) { if (encodingObject.getNumEx() != 0) {
...@@ -574,6 +592,12 @@ aspect ReverseParser{ ...@@ -574,6 +592,12 @@ aspect ReverseParser{
links.put(t.getKey(), t.getO().reverseLink(t.getO())); links.put(t.getKey(), t.getO().reverseLink(t.getO()));
response.setLinks(links); response.setLinks(links);
} }
if (r.getNumEx() != 0) {
Map<String, Object> extensions = new HashMap<>();
for (Extension e : r.getExList())
extensions.put(e.getKey(), e.getValue());
response.setExtensions(extensions);
}
return response; return response;
} }
...@@ -715,6 +739,12 @@ eq ExampleReference.reverseExample(ExampleOb exampleOb){ ...@@ -715,6 +739,12 @@ eq ExampleReference.reverseExample(ExampleOb exampleOb){
} }
if (h.hasS()) if (h.hasS())
header.setSchema(h.getS().reverseSchema(h.getS())); header.setSchema(h.getS().reverseSchema(h.getS()));
if (h.getNumEx() != 0){
Map<String, Object> extensions = new HashMap<>();
for(Extension e : h.getExList())
extensions.put(e.getKey(), e.getValue());
header.setExtensions(extensions);
}
return header; return header;
} }
...@@ -884,6 +914,10 @@ eq ExampleReference.reverseExample(ExampleOb exampleOb){ ...@@ -884,6 +914,10 @@ eq ExampleReference.reverseExample(ExampleOb exampleOb){
xml.setAttribute(xmlObject.getAttribute()); xml.setAttribute(xmlObject.getAttribute());
if (xmlObject.getWrapped() != null) if (xmlObject.getWrapped() != null)
xml.setWrapped(xmlObject.getWrapped()); xml.setWrapped(xmlObject.getWrapped());
if (xmlObject.getNumEx() != 0) {
for ( Extension e : xmlObject.getExList() )
xml.addExtension(e.getKey(), e.getValue());
}
return xml; return xml;
} }
......
openapi: "3.1.0"
x-oas-internal: test reserved keyword
x-oai-extension: test reserved keyword
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
identifier: test
servers:
- url: http://petstore.swagger.io/v1
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
description: pet
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully
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
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:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: error
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
"201":
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"
/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
- $ref: "#/components/parameters/User"
description: user
summary: user
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
parameters:
User:
in: query
description: user
name: user
schema:
type: string
schemas:
Pet:
type:
- object
- string
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
testenum:
type: string
enum:
- available
- pending
- sold
default: available
testconst:
type: string
const: pending
tag:
type: string
arbitraryKeyword: test
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
tag:
$ref: "#/components/schemas/Tag"
Tag:
type:
- object
- string
- string
- foo
properties:
id:
type: integer
format: int64
name:
type: string
openapi: "3.1.0"
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
info:
version: 1.0.0
summary: test summary in info object
description: description in info object
title: Swagger Petstore
license:
name: MIT
identifier: test identifier
servers:
- url: http://petstore.swagger.io/v1
- url: http://{host}.swagger.io/v1
variables:
host:
default: demo
description: this value is assigned by the service provider
enum: []
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
description: pet
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully
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
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:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: error
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
"201":
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"
/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
- $ref: "#/components/parameters/User"
description: user
summary: user
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
pathItems:
pets:
get:
description: Returns all pets from the system that the user has access to
responses:
'200':
description: A list of pets.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/pet'
parameters:
User:
in: query
description: user
name: user
schema:
type: string
schemas:
Pet:
type:
- object
- string
- array
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
writeOnly: true
readOnly: true
testenum:
type: string
enum:
- available
- pending
- sold
default: available
testconst:
type: string
const: pending
tag:
type: string
arbitraryKeyword: test
$ref: ./ex.json#user-profile
Pets:
type: 'null'
default: "I'm a string"
exclusiveMaximum: 12
exclusiveMinimum: 1
items:
$ref: "#/components/schemas/Pet"
ArrayWithoutItems:
type: array
ItemsWithoutArrayType:
type: object
items:
item1:
type: object
item2:
type: string
item3: what
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
tag:
$ref: "#/components/schemas/Tag"
Tag:
type:
- object
- string
- string
- foo
properties:
id:
type: integer
format: int64
name:
type: string
patternProperties:
'[a-b].*': 1
MapAnyValue:
additionalProperties: { }
openapi: 3.1.0
info:
version: "1.0.0"
title: parse-api
description: Test swagger-parser
paths:
/parse:
get:
description: Parser test
operationId: getParse
parameters:
- in: query
name: parse
required: true
schema:
$ref: 'http://localhost:${dynamicPort}/domain#/components/schemas/Parse'
- in: query
name: relativeParse
required: true
schema:
$ref: './domain.yaml#/components/schemas/Parse'
responses:
'200':
description: OK
content:
"application/json":
schema:
$ref: './domain.yaml#/components/schemas/Parse'
openapi: 3.1.0
info:
title: Parser Test
version: '1.0'
components:
schemas:
Parse:
$ref: '#/components/schemas/ParseEnum'
description: Overwritten description
ParseEnum:
title: Parse It
description: Can it parse it?
type:
- string
- object
enum:
- Yes
- No
NestedRef:
$ref: './domainref.yaml#/components/schemas/Parse'
openapi: 3.1.0
info:
title: Parser Test
version: '1.0'
components:
schemas:
NestedParse:
$ref: '#/components/schemas/NestedParseEnum'
description: Overwritten description
NestedParseEnum:
title: Parse It
description: Can it parse it?
type:
- string
- object
enum:
- Yes
- No
openapi: 3.1.0
info:
version: "1.0.0"
title: parse-api
description: Test swagger-parser
paths:
/parse:
get:
description: Parser test
operationId: getParse
parameters:
- in: query
name: parse
required: true
schema:
$ref: 'http://localhost:${dynamicPort}/domain#/components/schemas/Parse'
- in: query
name: relativeParse
required: true
schema:
$ref: './domain.yaml#/components/schemas/Parse'
responses:
'200':
description: OK
content:
"application/json":
schema:
$ref: './nested/domain.yaml#/components/schemas/NestedRef'
openapi: "3.1.0"
x-oas-internal: test reserved keyword
x-oai-extension: test reserved keyword
jsonSchemaDialect: 'https://json-schema.org/draft/2020-12/schema'
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
identifier: test
servers:
- url: http://petstore.swagger.io/v1
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
description: pet
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully
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
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:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: error
security:
- mutualTLS: [ ]
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
"201":
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"
/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
- $ref: "#/components/parameters/User"
description: user
summary: user
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
parameters:
User:
in: query
description: user
name: user
schema:
type: string
schemas:
Pet:
type:
- object
- string
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
testenum:
type: string
enum:
- available
- pending
- sold
default: available
testconst:
type: string
const: pending
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
tag:
$ref: "#/components/schemas/Tag"
Tag:
type:
- object
- string
- string
- foo
properties:
id:
type: integer
format: int64
name:
type: string
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
identifier: test
servers:
- url: http://petstore.swagger.io/v1
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully
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
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:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- 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
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type:
- string
- integer
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
identifier: test
servers:
- url: http://petstore.swagger.io/v1
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
x-extension: test
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
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:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- 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
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type:
- string
- integer
tag:
type: string
Pets:
$id: test
$anchor: test
type: array
items:
$ref: "#/components/schemas/Pet"
description: desc
format: int32
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
DiscriminatorExtension:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Lizard'
discriminator:
propertyName: petType
x-extension: test
pathItems:
pets:
get:
description: Returns all pets from the system that the user has access to
responses:
'200':
description: A list of pets.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/pet'
openapi: 3.1.0
info:
title: siblings JSONSchema
version: 1.0.0
servers:
- url: /
paths: { }
components:
schemas:
Payment:
type: object
properties:
name:
type: string
credit_card:
type: number
billing_address:
type: string
required:
- name
dependentRequired:
credit_card:
- billing_address
PaymentMethod:
type: object
properties:
name:
type: string
credit_card:
type: number
required:
- name
dependentSchemas:
credit_card:
properties:
billing_address:
type: string
required:
- billing_address
IfTest:
title: Person
type: object
properties:
country:
type: string
widget: Select
enum:
- usa
- canada
- eu
default: eu
required:
- country
if:
properties:
country:
type: string
const: canada
then:
properties:
maple_trees:
type: number
else:
properties:
accept:
type: boolean
const: true
required:
- accept
Fruit:
type: string
examples:
- apple
- orange
Error:
type: object
properties:
code:
type: integer
message:
type: string
examples:
- code: 123
message: Oops...
- code: 456
message: Feature is not available for your plan
openapi: 3.1.0
servers:
- url: /v2
info:
version: 1.0.0
title: Swagger Petstore
paths:
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
responses:
'405':
description: Invalid input
security:
- api_key: []
requestBody:
$ref: '#/components/requestBodies/Pet'
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
responses:
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
$ref: '#/components/requestBodies/Pet'
/petType:
post:
tags:
- petType
summary: Add a new pet to the store
description: ''
operationId: addPet
responses:
'405':
description: Invalid input
security:
- mutual_TLS: [ ]
requestBody:
$ref: '#/components/requestBodies/Pet'
components:
requestBodies:
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
securitySchemes:
petstore_auth:
type: oauth2
description: This is a description
flows:
implicit:
authorizationUrl: 'http://petstore.swagger.io/oauth/dialog'
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
api_key:
type: apiKey
name: api_key
description: This is another description
in: header
mutual_TLS:
type: mutualTLS
name: name mutualTLS
description: This is another description
in: header
schemas:
Pet:
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
name:
type: string
example: doggie
photoUrls:
type: array
xml:
name: photoUrl
wrapped: true
items:
type: string
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: Pet
\ No newline at end of file
...@@ -62,7 +62,7 @@ public class OpenAPIMain_test { ...@@ -62,7 +62,7 @@ public class OpenAPIMain_test {
.replace("~1", "/") .replace("~1", "/")
.replace("\"", ""); .replace("\"", "");
for (String s : pathNode.split("\\.")) { for (String s : pathNode.split("\\.")) {
if ( !s.contains("['") && isNumeric(s) && Integer.parseInt(s) < 100) if ( !s.contains("['") && isNumeric(s) && Integer.parseInt(s) < 200)
result = result.concat("[" + s + "]."); result = result.concat("[" + s + "].");
else else
result = result.concat(s + "."); result = result.concat(s + ".");
...@@ -71,14 +71,14 @@ public class OpenAPIMain_test { ...@@ -71,14 +71,14 @@ public class OpenAPIMain_test {
pathNode = result.substring(0, result.length()-1); pathNode = result.substring(0, result.length()-1);
//System.out.println(JsonPath.parse(expectedNode.toString()).read(pathNode, String.class)); //System.out.println(JsonPath.parse(expectedNode.toString()).read(pathNode, String.class));
//System.out.println(JsonPath.parse(actualNode.toString()).read(pathNode, String.class)); //System.out.println(JsonPath.parse(actualNode.toString()).read(pathNode, String.class));
System.out.println(pathNode); //System.out.println(pathNode);
// check, if this node exists or has an empty value. // check, if this node exists or has an empty value.
if (JsonPath.parse(expectedNode.toString()).read(pathNode, String.class) == null || JsonPath.parse(expectedNode.toString()).read(pathNode, String.class).isEmpty()) if (JsonPath.parse(expectedNode.toString()).read(pathNode, String.class) == null || JsonPath.parse(expectedNode.toString()).read(pathNode, String.class).isEmpty())
((ArrayNode) diff).remove(i); ((ArrayNode) diff).remove(i);
else if (JsonPath.parse(actualNode.toString()).read(pathNode, String.class) == null || JsonPath.parse(actualNode.toString()).read(pathNode, String.class).isEmpty()) else if (JsonPath.parse(actualNode.toString()).read(pathNode, String.class) == null || JsonPath.parse(actualNode.toString()).read(pathNode, String.class).isEmpty())
((ArrayNode) diff).remove(i); ((ArrayNode) diff).remove(i);
else if (!JsonPath.parse(actualNode.toString()).read(pathNode.substring(0, pathNode.lastIndexOf(".")).concat(".$ref"), String.class).isEmpty()) //else if (!JsonPath.parse(actualNode.toString()).read(pathNode.substring(0, pathNode.lastIndexOf(".")).concat(".$ref"), String.class).isEmpty())
((ArrayNode) diff).remove(i); // ((ArrayNode) diff).remove(i);
result = ""; result = "";
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment