mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 21:36:13 +00:00
[Typescript]: add deprecated tags (#21436)
* Add deprecation markers
* Move inputSpec (avoid sharing with other generators)
* Generate samples
* Refactor unit tests
* Add test helper method
* Revert "Add test helper method"
This reverts commit d3935e87d9.
* Assert number of expected @deprecated
This commit is contained in:
@@ -32,6 +32,10 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
*
|
||||
{{/isDeprecated}}
|
||||
{{#notes}}
|
||||
* {{¬es}}
|
||||
{{/notes}}
|
||||
@@ -39,7 +43,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
|
||||
* {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{paramName}} {{description}}
|
||||
* @param {{paramName}} {{description}}{{#isDeprecated}} (@deprecated){{/isDeprecated}}
|
||||
{{/allParams}}
|
||||
*/
|
||||
public async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}_options?: Configuration): Promise<RequestContext> {
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
@@ -177,6 +179,21 @@ public class TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count occurrences of the given text
|
||||
* @param content content of the file
|
||||
* @param text text to find
|
||||
* @return
|
||||
*/
|
||||
public static int countOccurrences(String content, String text) {
|
||||
Matcher matcher = Pattern.compile(text).matcher(content);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String linearize(String target) {
|
||||
return target.replaceAll("\r?\n", "").replaceAll("\\s+", "\\s");
|
||||
}
|
||||
|
||||
@@ -15,11 +15,14 @@ import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@Test(groups = {TypeScriptGroups.TYPESCRIPT})
|
||||
public class TypeScriptClientCodegenTest {
|
||||
@Test
|
||||
@@ -210,4 +213,58 @@ public class TypeScriptClientCodegenTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeprecatedOperation() throws Exception {
|
||||
final File output = Files.createTempDirectory("typescriptnodeclient_").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("typescript")
|
||||
.setInputSpec("src/test/resources/3_0/typescript/deprecated-operation.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
final DefaultGenerator generator = new DefaultGenerator();
|
||||
final List<File> files = generator.opts(clientOptInput).generate();
|
||||
files.forEach(File::deleteOnExit);
|
||||
|
||||
// verify operation is deprecated
|
||||
Path file = Paths.get(output + "/apis/DefaultApi.ts");
|
||||
TestUtils.assertFileContains(
|
||||
file,
|
||||
"* @deprecated"
|
||||
);
|
||||
|
||||
String content = Files.readString(file);
|
||||
assertEquals(1, TestUtils.countOccurrences(content, "@deprecated"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeprecatedParameter() throws Exception {
|
||||
final File output = Files.createTempDirectory("typescriptnodeclient_").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("typescript")
|
||||
.setInputSpec("src/test/resources/3_0/typescript/deprecated-parameter.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
final DefaultGenerator generator = new DefaultGenerator();
|
||||
final List<File> files = generator.opts(clientOptInput).generate();
|
||||
files.forEach(File::deleteOnExit);
|
||||
|
||||
// verify parameter is deprecated parameter
|
||||
Path file = Paths.get(output + "/apis/DefaultApi.ts");
|
||||
TestUtils.assertFileContains(
|
||||
file,
|
||||
"* @param name name of pet (@deprecated)"
|
||||
);
|
||||
|
||||
String content = Files.readString(file);
|
||||
assertEquals(1, TestUtils.countOccurrences(content, "@deprecated"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: test order parameters
|
||||
version: 1.0.0
|
||||
title: Test order parameters
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
tags:
|
||||
- default
|
||||
summary: Finds Pets
|
||||
deprecated: true
|
||||
description: Find all pets
|
||||
operationId: findPets
|
||||
parameters:
|
||||
- name: type
|
||||
in: query
|
||||
description: type of pet
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
default: available
|
||||
- name: name
|
||||
in: query
|
||||
description: name of pet
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: age
|
||||
in: query
|
||||
description: age of pet
|
||||
schema:
|
||||
type: number
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
'400':
|
||||
description: Invalid status value
|
||||
@@ -0,0 +1,43 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: test order parameters
|
||||
version: 1.0.0
|
||||
title: Test order parameters
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
tags:
|
||||
- default
|
||||
summary: Finds Pets
|
||||
description: Find all pets
|
||||
operationId: findPets
|
||||
parameters:
|
||||
- name: type
|
||||
in: query
|
||||
description: type of pet
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
default: available
|
||||
- name: name
|
||||
in: query
|
||||
deprecated: true
|
||||
description: name of pet
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: age
|
||||
in: query
|
||||
description: age of pet
|
||||
schema:
|
||||
type: number
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
'400':
|
||||
description: Invalid status value
|
||||
@@ -0,0 +1,918 @@
|
||||
#
|
||||
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Echo Server API
|
||||
description: Echo Server API
|
||||
contact:
|
||||
email: team@openapitools.org
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: http://localhost:3000/
|
||||
paths:
|
||||
# Path usually starts with parameter type such as path, query, header, form
|
||||
# For body/form parameters, path starts with "/echo" so the echo server
|
||||
# will respond with the same body in the HTTP request.
|
||||
#
|
||||
# path parameter tests
|
||||
/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}:
|
||||
get:
|
||||
tags:
|
||||
- path
|
||||
summary: Test path parameter(s)
|
||||
description: Test path parameter(s)
|
||||
operationId: tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}
|
||||
parameters:
|
||||
- in: path
|
||||
name: path_string
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: path_integer
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
- in: path
|
||||
name: enum_nonref_string_path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
- in: path
|
||||
name: enum_ref_string_path
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# form parameter tests
|
||||
/form/integer/boolean/string:
|
||||
post:
|
||||
tags:
|
||||
- form
|
||||
summary: Test form parameter(s)
|
||||
description: Test form parameter(s)
|
||||
operationId: test/form/integer/boolean/string
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
integer_form:
|
||||
type: integer
|
||||
boolean_form:
|
||||
type: boolean
|
||||
string_form:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# form parameter tests for oneOf schema
|
||||
/form/oneof:
|
||||
post:
|
||||
tags:
|
||||
- form
|
||||
summary: Test form parameter(s) for oneOf schema
|
||||
description: Test form parameter(s) for oneOf schema
|
||||
operationId: test/form/oneof
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
oneOf:
|
||||
- type: object
|
||||
properties:
|
||||
form1:
|
||||
type: string
|
||||
form2:
|
||||
type: integer
|
||||
- type: object
|
||||
properties:
|
||||
form3:
|
||||
type: string
|
||||
form4:
|
||||
type: boolean
|
||||
- $ref: '#/components/schemas/Tag'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/form/object/multipart:
|
||||
post:
|
||||
tags:
|
||||
- form
|
||||
summary: Test form parameter(s) for multipart schema
|
||||
description: Test form parameter(s) for multipart schema
|
||||
operationId: test/form/object/multipart
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- marker
|
||||
properties:
|
||||
marker:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# header parameter tests
|
||||
/header/integer/boolean/string/enums:
|
||||
get:
|
||||
tags:
|
||||
- header
|
||||
summary: Test header parameter(s)
|
||||
description: Test header parameter(s)
|
||||
operationId: test/header/integer/boolean/string/enums
|
||||
parameters:
|
||||
- in: header
|
||||
name: integer_header
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: integer
|
||||
- in: header
|
||||
name: boolean_header
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: boolean
|
||||
- in: header
|
||||
name: string_header
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
- in: header
|
||||
name: enum_nonref_string_header
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
- in: header
|
||||
name: enum_ref_string_header
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# query parameter tests
|
||||
/query/enum_ref_string:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/enum_ref_string
|
||||
parameters:
|
||||
- in: query
|
||||
name: enum_nonref_string_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
- in: query
|
||||
name: enum_ref_string_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/datetime/date/string:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/datetime/date/string
|
||||
parameters:
|
||||
- in: query
|
||||
name: datetime_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
- in: query
|
||||
name: date_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
format: date
|
||||
- in: query
|
||||
name: string_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/integer/boolean/string:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/integer/boolean/string
|
||||
parameters:
|
||||
- in: query
|
||||
name: integer_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: integer
|
||||
- in: query
|
||||
name: boolean_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: boolean
|
||||
- in: query
|
||||
name: string_query
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_form/explode_true/array_string:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_form/explode_true/array_string
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
values:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_form/explode_false/array_integer:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_form/explode_false/array_integer
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: form #default
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_form/explode_false/array_string:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_form/explode_false/array_string
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: form #default
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_form/explode_true/object:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_form/explode_true/object
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_form/explode_true/object/allOf:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_form/explode_true/object/allOf
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: form #default
|
||||
explode: true #default
|
||||
schema:
|
||||
$ref: '#/components/schemas/DataQuery'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_deepObject/explode_true/object:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_deepObject/explode_true/object
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: deepObject
|
||||
explode: true #default
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/query/style_deepObject/explode_true/object/allOf:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
summary: Test query parameter(s)
|
||||
description: Test query parameter(s)
|
||||
operationId: test/query/style_deepObject/explode_true/object/allOf
|
||||
parameters:
|
||||
- in: query
|
||||
name: query_object
|
||||
style: deepObject
|
||||
explode: true #default
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Bird'
|
||||
- $ref: '#/components/schemas/Category'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# body parameter tests
|
||||
/body/application/octetstream/binary:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test body parameter(s)
|
||||
description: Test body parameter(s)
|
||||
operationId: test/body/application/octetstream/binary
|
||||
requestBody:
|
||||
content:
|
||||
application/octet-stream:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/echo/body/Pet:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test body parameter(s)
|
||||
description: Test body parameter(s)
|
||||
operationId: test/echo/body/Pet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
/echo/body/allOf/Pet:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test body parameter(s)
|
||||
description: Test body parameter(s)
|
||||
operationId: test/echo/body/allOf/Pet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/AllOfPet'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
/echo/body/Pet/response_string:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test empty response body
|
||||
description: Test empty response body
|
||||
operationId: test/echo/body/Pet/response_string
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/echo/body/Tag/response_string:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test empty json (request body)
|
||||
description: Test empty json (request body)
|
||||
operationId: test/echo/body/Tag/response_string
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Tag'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/echo/body/FreeFormObject/response_string:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test free form object
|
||||
description: Test free form object
|
||||
operationId: test/echo/body/FreeFormObject/response_string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
description: Free form object
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/echo/body/string_enum:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test string enum response body
|
||||
description: Test string enum response body
|
||||
operationId: test/echo/body/string_enum
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
description: String enum
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
/binary/gif:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test binary (gif) response body
|
||||
description: Test binary (gif) response body
|
||||
operationId: test/binary/gif
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
image/gif:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
# Single binary in multipart mime test
|
||||
/body/application/octetstream/single_binary:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test single binary in multipart mime
|
||||
description: Test single binary in multipart mime
|
||||
operationId: test/body/multipart/formdata/single_binary
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
my-file:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# Array of binary in multipart mime tests
|
||||
/body/application/octetstream/array_of_binary:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test array of binary in multipart mime
|
||||
description: Test array of binary in multipart mime
|
||||
operationId: test/body/multipart/formdata/array_of_binary
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
required:
|
||||
- files
|
||||
type: object
|
||||
properties:
|
||||
files:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# To test http basic auth
|
||||
/auth/http/basic:
|
||||
post:
|
||||
tags:
|
||||
- auth
|
||||
security:
|
||||
- http_auth: []
|
||||
summary: To test HTTP basic authentication
|
||||
description: To test HTTP basic authentication
|
||||
operationId: test/auth/http/basic
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
# To test http bearer auth
|
||||
/auth/http/bearer:
|
||||
post:
|
||||
tags:
|
||||
- auth
|
||||
security:
|
||||
- http_bearer_auth: []
|
||||
summary: To test HTTP bearer authentication
|
||||
description: To test HTTP bearer authentication
|
||||
operationId: test/auth/http/bearer
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/test/deprecated:
|
||||
get:
|
||||
tags:
|
||||
- query
|
||||
deprecated: true
|
||||
summary: Test deprecation
|
||||
operationId: deprecated-test
|
||||
parameters:
|
||||
- name: name
|
||||
in: query
|
||||
deprecated: true
|
||||
description: name of pet
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
components:
|
||||
securitySchemes:
|
||||
http_auth:
|
||||
type: http
|
||||
scheme: basic
|
||||
http_bearer_auth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
requestBodies:
|
||||
Pet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
AllOfPet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
Tag:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
description: Tag object
|
||||
schemas:
|
||||
Category:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
example: 1
|
||||
name:
|
||||
type: string
|
||||
example: Dogs
|
||||
xml:
|
||||
name: category
|
||||
Tag:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
xml:
|
||||
name: tag
|
||||
Pet:
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
example: 10
|
||||
name:
|
||||
type: string
|
||||
example: doggie
|
||||
category:
|
||||
$ref: '#/components/schemas/Category'
|
||||
photoUrls:
|
||||
type: array
|
||||
xml:
|
||||
wrapped: true
|
||||
items:
|
||||
type: string
|
||||
xml:
|
||||
name: photoUrl
|
||||
tags:
|
||||
type: array
|
||||
xml:
|
||||
wrapped: true
|
||||
items:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
status:
|
||||
type: string
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
xml:
|
||||
name: pet
|
||||
StringEnumRef:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
DefaultValue:
|
||||
type: object
|
||||
description: to test the default value of properties
|
||||
properties:
|
||||
array_string_enum_ref_default:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/StringEnumRef'
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
array_string_enum_default:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- failure
|
||||
- unclassified
|
||||
default:
|
||||
- success
|
||||
- failure
|
||||
array_string_default:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default:
|
||||
- failure
|
||||
- skipped
|
||||
array_integer_default:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
default:
|
||||
- 1
|
||||
- 3
|
||||
array_string:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
array_string_nullable:
|
||||
nullable: true
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
array_string_extension_nullable:
|
||||
x-nullable: true
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
string_nullable:
|
||||
type: string
|
||||
nullable: true
|
||||
Bird:
|
||||
type: object
|
||||
properties:
|
||||
size:
|
||||
type: string
|
||||
color:
|
||||
type: string
|
||||
Query:
|
||||
type: object
|
||||
x-parent: true
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: Query
|
||||
format: int64
|
||||
outcomes:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- SUCCESS
|
||||
- FAILURE
|
||||
- SKIPPED
|
||||
default:
|
||||
- SUCCESS
|
||||
- FAILURE
|
||||
DataQuery:
|
||||
allOf:
|
||||
- type: object
|
||||
properties:
|
||||
suffix:
|
||||
type: string
|
||||
description: test suffix
|
||||
text:
|
||||
type: string
|
||||
description: Some text containing white spaces
|
||||
example: "Some text"
|
||||
date:
|
||||
type: string
|
||||
format: date-time
|
||||
description: A date
|
||||
- $ref: '#/components/schemas/Query'
|
||||
NumberPropertiesOnly:
|
||||
type: object
|
||||
properties:
|
||||
number:
|
||||
type: number
|
||||
float:
|
||||
type: number
|
||||
format: float
|
||||
double:
|
||||
type: number
|
||||
format: double
|
||||
minimum: 0.8
|
||||
maximum: 50.2
|
||||
Reference in New Issue
Block a user