-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] The generator generates invalid value for the "example" field #5710
Labels
Comments
I have a similar issue with an additional question... I can almost get it... // ###########################################################################################
{{#openAPI}}
// #Openapi: {{{openapi}}}
{{#components}}
// #components: {{{openapi}}}
{{#examples}}
// #examples
{{#Example}}
// /Example
{{/Example}}
{{#this}}
// #this: {{{.}}}
{{/this}}
// /examples
{{/examples}}
// /components
{{/components}}
// /openAPI
{{/openAPI}} Which gives me
But how do I iterate over the list of examples ? # java -jar openapi-generator-cli.jar generate -g rust --library reqwest -i junk/test_api.yaml -o test
openapi: 3.0.0
info:
title: Junk
description: 'RESTful API, minimal'
version: v1.0
paths:
'/test':
get:
operationId: APIGet
summary: Server Configurations Settings
responses:
'401':
$ref: '#/components/responses/Unauthorized'
servers:
- url: '{scheme}://127.0.0.1:/api'
variables:
scheme:
enum:
- 'http'
- 'https'
default: https
description: Default to HTTPS
port:
default: '8080'
- url: 'http://127.0.0.1:8080'
components:
schemas:
# ----------------------------------------------------
# -------------- Type definitions --------------
# ----------------------------------------------------
# $ref: '#/components/schemas/TypeUSHORT'
TypeUSHORT:
type: integer
format: int32
minimum: 0
maximum: 65535
# $ref: '#/components/schemas/TypeEnumModeActive'
TypeEnumModeActive:
default: Active
enum:
- Active
- Backup
# $ref: '#/components/schemas/TypeIPAddress'
TypeIPAddress:
type: string
pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
maximum: 15
description: Assign an IP address to the wireless network. Note, Applicable only if Client Traffic is selected as 'Separate Zone'..
# $ref: '#/components/schemas/TypeRouteWeight'
TypeRouteWeight:
type: integer
format: int32
minimum: 0
maximum: 256
default: 1
nullable: true
description: 'Weight which determines how much traffic will pass through a particular link relative to the other link.'
# $ref: '#/components/schemas/TypeEnumActivationAction'
TypeEnumActivationAction:
default: InheritWeight
enum:
- InheritWeight
- UseCustomWeight
# $ref: '#/components/schemas/TypeEnumIPFamily'
TypeEnumIPFamily:
default: IPv4
enum:
- IPv4
- IPv6
# $ref: '#/components/schemas/TypeString50'
TypeString50:
type: string
maxLength: 50
nullable: true
# $ref: '#/components/schemas/TypeIdentifier10'
TypeIdentifier10:
type: string
pattern: '^[^,]*$'
maxLength: 10
nullable: false
description: '10 character Identifier Character not allowed, Comma (,)'
# $ref: '#/components/schemas/TypeUserID'
# ----------------------------------------------------
# ------------ Structure definitions ------------
# ----------------------------------------------------
TimeEntry:
title: Time Entry
type: object
properties:
Time:
type: string
description: Time entry
#example:
# summary: example
# $ref: '#/components/examples/'
# $ref: '#/components/schemas/TimeArray'
TimeArray:
title: Time Entry
type: array
items:
$ref: '#/components/schemas/TimeEntry'
#example:
# summary: example
# $ref: '#/components/examples/'
Gateway:
description: Gateway Descriptor
type: object
properties:
Name:
$ref: '#/components/schemas/TypeIdentifier10'
description: Name for LAG interface. Character not allowed, Comma (,)
IPFamily:
$ref: '#/components/schemas/TypeEnumIPFamily'
IPAddress:
$ref: '#/components/schemas/TypeIPAddress'
nullable: true
description: Used to set IPv4 address for interface in IPv4 configuration. Datatype is 'IPADDRESS'. Maximum characters allowed are 15.
Type:
$ref: '#/components/schemas/TypeEnumModeActive'
Weight:
$ref: '#/components/schemas/TypeRouteWeight'
ActivateGatewayOnFailureOf:
type: string
nullable: false
description: "Gateway Activation Condition: Any/All/{GWName}/Manual or Custom."
ActionOnActivation:
$ref: '#/components/schemas/TypeEnumActivationAction'
ActionOnFailback:
enum:
- ServeNewConnections
- ServeAllConnections
default: ServeAllConnections
description: "action for existing and new connections after failback. 1 - Serves all connections through the restored gateway. This interrupts existing connection"
CustomWeight:
$ref: '#/components/schemas/TypeRouteWeight'
description: "Use this tag only when <ActionOnActivation>has value 'UseCustomWeight'"
NATPolicy:
$ref: '#/components/schemas/TypeIdentifier10'
description: "Name of NAT Policy interface. Character not allowed, Comma (,)"
FailOverRules:
type: array
items:
$ref: '#/components/schemas/GWFailOverRule'
example:
summary: Failover Rule example
$ref: '#/components/examples/ExFragGateway'
FailOverRules:
description: Gateway Failover rules Descriptor
type: object
properties:
GatewayName:
$ref: '#/components/schemas/TypeString50'
IPFamily:
$ref: '#/components/schemas/TypeEnumIPFamily'
Rule:
type: array
items:
$ref: '#/components/schemas/GWFailOverRule'
GWFailOverRule:
description: Gateway Failover rule
type: object
properties:
Protocol:
nullable: true
enum:
- PING
- TCP
default: PING
description: "action for existing and new connections after failback. 1 - Serves all connections through the restored gateway. This interrupts existing connection"
IPAddress:
$ref: '#/components/schemas/TypeIPAddress'
nullable: false
description: "Used to set IPv4 address for interface in IPv4 configuration. Datatype is 'IPADDRESS'. Maximum characters allowed are 15."
# ip
Port:
nullable: true
$ref: '#/components/schemas/TypeUSHORT'
Condition:
enum:
- AND
- OR
default: OR
description: "Rule order matters as this condition will apply on next rule -->"
example:
summary: Failover Rule example
$ref: '#/components/examples/ExFragRule'
examples:
ExFragRule:
value: <Rule>
<Protocol>PING</Protocol>
<IPAddress>192.168.253.1</IPAddress>
<Port>*</Port>
<Condition/>
</Rule>
ExFragFailoverRules:
value: <FailOverRules>
<Rule>
<Protocol>PING</Protocol>
<IPAddress>192.168.253.1</IPAddress>
<Port>*</Port>
<Condition/>
</Rule>
</FailOverRules>
ExFragGateway:
value: <Gateway>
<Name>Spectrum_Port2_GW</Name>
<IPFamily>IPv4</IPFamily>
<IPAddress>192.168.253.1</IPAddress>
<Type>Active</Type>
<Weight>1</Weight>
<NATPolicy>MASQ</NATPolicy>
<FailOverRules>
<Rule>
<Protocol>PING</Protocol>
<IPAddress>192.168.253.1</IPAddress>
<Port>*</Port>
<Condition/>
</Rule>
</FailOverRules>
</Gateway>
securitySchemes:
basic:
type: http
scheme: basic
responses:
Unauthorized:
description: Authentication Failure.
content:
'application/xml':
examples:
def:
value: <?xml version="1.0" encoding="UTF-8"?>
<Response>
<Login>
<status>Authentication Failure</status>
</Login>
</Response>
security:
- basic: []
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
Sometimes, the generated value for "example" fields are wrong.
openapi-generator version
4.2.3
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
openapi-generator generate -i sample.yaml -g asciidoc -v
example
field should have the valuefoofoobazbarfoo
but it hasxCustom_example
:Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: