-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When I'm trying to build code generated from the OpenApi spec file with "anyOf", it fails because of the lack of "AnyOfAWSPreferenceAzurePreference" class.
openapi-generator version
5.1.1
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Preferences Core API
version: 1.0.0
tags:
- name: Preferences
description: Operations for preferences
security:
- api_key: [ ]
paths:
/preferences:
get:
summary: Returns preferences based on parameters
tags:
- Preferences
parameters:
- $ref: '#/components/parameters/Accept'
responses:
'200':
$ref: '#/components/responses/GetPreferencesListResponse'
components:
parameters:
Accept:
name: Accept
in: header
description: Defines acceptable resource representations
required: false
schema:
type: string
default: application/json
responses:
GetPreferencesListResponse:
description: Describes the success response for the get preferences operation
content:
application/json:
schema:
$ref: '#/components/schemas/PreferencesListWithIds'
securitySchemes:
api_key:
type: apiKey
name: x-api-key
in: header
schemas:
PreferencesType:
type: string
enum:
- AWS
- AZURE
- TERRAFORM
- GITLAB
AWSPreferenceType:
type: string
enum:
- ACCESS_KEY_ID
- ACCESS_KEY_SECRET
AzurePreferenceType:
type: string
enum:
- CLIENT_ID
- CLIENT_SECRET
- SUBSCRIPTION_ID
- TENANT_ID
PreferencesListWithIds:
type: array
items:
$ref: '#/components/schemas/PreferencesWithId'
PreferencesWithId:
allOf:
- properties:
id:
type: string
- $ref: '#/components/schemas/Preferences'
Preferences:
properties:
programId:
type: string
projectId:
type: string
labels:
type: array
items:
type: string
type:
$ref: '#/components/schemas/PreferencesType'
preferences:
type: array
items:
anyOf:
- $ref: '#/components/schemas/AWSPreference'
- $ref: '#/components/schemas/AzurePreference'
required:
- type
- preferences
Preference:
type: object
properties:
name:
type: string
value:
type: string
encrypted:
type: boolean
required:
- encrypted
- name
- value
AWSPreference:
allOf:
- $ref: '#/components/schemas/Preference'
- type: object
properties:
name:
$ref: '#/components/schemas/AWSPreferenceType'
AzurePreference:
allOf:
- $ref: '#/components/schemas/Preference'
- type: object
properties:
name:
$ref: '#/components/schemas/AzurePreferenceType'
Generation Details
{
"dateLibrary": "java8",
"java8": true,
"library": "native",
"sourceFolder": "src/main/java",
"serializationLibrary": "jackson"
}Steps to reproduce
I'm using this script:
#!/usr/bin/env bash
[ ! -f openapi-generator-cli.jar ] && wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar -O openapi-generator-cli.jar
LAYER=$1
SERVICE_NAME=$2
SPEC_FILE=$3
VERSION=$4
MODULE_PACKAGE=$(echo "$LAYER.$SERVICE_NAME")
MODULE_ARTIFACT=$(echo "$LAYER-$SERVICE_NAME-spec-api")
TMP_DIR=$SERVICE_NAME
rm -fr $TMP_DIR
java -jar openapi-generator-cli.jar config-help -g java > help-java.txt
java -jar openapi-generator-cli.jar generate \
--global-property models,modelTests=false,apis,supportingFiles \
--additional-properties=apiPackage=io.$MODULE_PACKAGE.api \
--additional-properties=artifactDescription=$SPEC_FILE \
--additional-properties=artifactVersion=$VERSION \
--additional-properties=artifactId=$MODULE_ARTIFACT \
--additional-properties=groupId=io.$LAYER \
--additional-properties=invokerPackage=io.$MODULE_PACKAGE.client \
--additional-properties=modelPackage=io.$MODULE_PACKAGE.api \
-i $SPEC_FILE \
-g java \
-c java-config.json \
-o $TMP_DIR
cp -r .mvn $TMP_DIRcall it with:
sh generate-models.sh feature preferences Governance-Core-PreferencesAPI-Target-V1.0.yaml 1.0.0
Related issues/PRs
Suggest a fix
Reactions are currently unavailable