Skip to content

Commit

Permalink
Ensure description is always set for top-level oneOf schemas (#2127)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin authored Apr 19, 2024
1 parent ea19b3f commit a5f0805
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/autorest.bicep/src/schema-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ export function generateSchema(host: AutorestExtensionHost, definition: Provider
oneOf.push(childSchema);
}

schema.oneOf = oneOf;
if (oneOf.length > 0) {
schema.oneOf = oneOf;
}
}

function processResourceBody(fullyQualifiedType: string, definition: ResourceDefinition, isChildDefinition: boolean) {
Expand All @@ -358,7 +360,6 @@ export function generateSchema(host: AutorestExtensionHost, definition: Provider

const schema: JSONSchema4 = {
type: 'object',
description: getFullyQualifiedType(descriptor),
properties: {
name,
},
Expand Down Expand Up @@ -403,6 +404,7 @@ export function generateSchema(host: AutorestExtensionHost, definition: Provider
}

function addResourceTypeAndApiVersion(descriptor: ResourceDescriptor, schema: JSONSchema4, isChildDefinition: boolean): JSONSchema4 {
schema.description ??= getFullyQualifiedType(descriptor),
schema.properties ??= {};
schema.required ??= [];

Expand Down

0 comments on commit a5f0805

Please sign in to comment.