You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openapi: "3.0.0"
info:
title: API-Template
description: |
Single or multilined API description. Can be written on HTML or [CommonMark](http://commonmark.org/help/)
version: v1
tags:
- name: Customers
description: "Operations and resources related to customers"
paths:
/customers/{customerId}:
parameters:
- $ref: '#/components/parameters/customerIdPathParam'
get:
summary: Retrieve customer information
description: Description for operation that allows retrieve customer information
operationId: retrieveCustomerInfo
tags:
- Customers
responses:
'200':
description: Customer response
content:
application/json:
schema:
$ref: '#/components/schemas/customer'
components:
parameters:
customerIdPathParam:
name: customerId
in: path
required: true
description: The id of the customer
schema:
$ref: '#/components/schemas/uuid'
schemas:
uuid:
type: string
format: uuid
minLength: 36
maxLength: 36
pattern: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
customer:
type: object
properties:
id:
description: The id of the customer
allOf:
- $ref: '#/components/schemas/uuid'
x-apigen-mapping:
field: id
Code executed:
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws IOException {
String api;
try (InputStream is = Main.class.getClassLoader().getResourceAsStream("template_error.yaml")) {
api = IOUtils.toString(is, StandardCharsets.UTF_8);
}
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveCombinators(true);
options.setResolveFully(true);
options.setFlatten(true);
OpenAPI openAPI = parser.readContents(api, null, options).getOpenAPI();
System.out.println(Yaml.mapper().writeValueAsString(openAPI));
}
}
Output:
openapi: 3.0.0
info:
title: API-Template
description: |
Single or multilined API description. Can be written on HTML or [CommonMark](http://commonmark.org/help/)
version: v1
servers:
- url: /
tags:
- name: Customers
description: Operations and resources related to customers
paths:
/customers/{customerId}:
get:
tags:
- Customers
summary: Retrieve customer information
description: Description for operation that allows retrieve customer information
operationId: retrieveCustomerInfo
parameters:
- name: customerId
in: path
description: The id of the customer
required: true
style: simple
explode: false
schema:
maxLength: 36
minLength: 36
pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
type: string
format: uuid
responses:
"200":
description: Customer response
content:
application/json:
schema:
$ref: '#/components/schemas/inline_response_200'
components:
schemas:
uuid:
maxLength: 36
minLength: 36
pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
type: string
format: uuid
customer:
type: object
properties:
id: {}
inline_response_200:
type: object
properties:
id: {}
parameters:
customerIdPathParam:
name: customerId
in: path
description: The id of the customer
required: true
style: simple
explode: false
schema:
maxLength: 36
minLength: 36
pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
type: string
format: uuid
Expected result:
The id property in the customer and inline_response_200 schemas should have content and not be an empty object.
Tried with versions 2.0.33 and 2.1.1 with same result.
Example with one schema property:
Code executed:
Output:
Expected result:
The
id
property in thecustomer
andinline_response_200
schemas should have content and not be an empty object.Tried with versions 2.0.33 and 2.1.1 with same result.
Seems a similar issue to #1367 but that was closed.
Thanks!
The text was updated successfully, but these errors were encountered: