Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/autorest.bicep/src/writers/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function writeMarkdown(provider: string, apiVersion: string, types: TypeB

const resourceTypes = orderBy(types.filter(t => t instanceof ResourceType) as ResourceType[], x => x.Name.split('@')[0].toLowerCase());
const resourceFunctionTypes = orderBy(types.filter(t => t instanceof ResourceFunctionType) as ResourceFunctionType[], x => x.Name.split('@')[0].toLowerCase());
const typesToWrite: TypeBase[] = [...resourceTypes, ...resourceFunctionTypes];
const typesToWrite: TypeBase[] = []

for (const resourceType of resourceTypes) {
findTypesToWrite(types, typesToWrite, resourceType.Body);
Expand All @@ -202,12 +202,24 @@ export function writeMarkdown(provider: string, apiVersion: string, types: TypeB
findTypesToWrite(types, typesToWrite, resourceFunctionType.Output);
}

for (const type of typesToWrite) {
typesToWrite.sort((a, b) => {
const aName = (a as ObjectType).Name?.toLowerCase();
const bName = (b as ObjectType).Name?.toLowerCase();

if (aName === undefined) {
return bName === undefined ? 0 : 1;
}
if (bName === undefined || aName < bName) return -1;
if (bName > aName) return 1;
return 0;
});

for (const type of (resourceTypes as TypeBase[]).concat(resourceFunctionTypes).concat(typesToWrite)) {
writeComplexType(types, type, 2, true);
}

return output;
}

return generateMarkdown(provider, apiVersion, types);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@
* **Input**: [FoosRequest](#foosrequest)
* **Output**: [FoosResponse](#foosresponse)

## TestType1Properties
## FoosRequest
### Properties
* **basicString**: string: Description for a basic string property.
* **skuTier**: 'Basic' | 'Free' | 'Premium' | 'Standard': This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
* **stringEnum**: 'Bar' | 'Foo' | string: Description for a basic enum property.
* **someString**: string (Required, WriteOnly): The foo request string

## FoosResponse
### Properties
* **someString**: string (ReadOnly): The foo response string

## FoosResponse
### Properties
* **someString**: string (ReadOnly): The foo response string

## SystemData
### Properties
Expand All @@ -38,20 +44,14 @@
* **lastModifiedBy**: string: The identity that last modified the resource.
* **lastModifiedByType**: 'Application' | 'Key' | 'ManagedIdentity' | 'User' | string: The type of identity that created the resource.

## TestType1Properties
### Properties
* **basicString**: string: Description for a basic string property.
* **skuTier**: 'Basic' | 'Free' | 'Premium' | 'Standard': This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
* **stringEnum**: 'Bar' | 'Foo' | string: Description for a basic enum property.

## TrackedResourceTags
### Properties
### Additional Properties
* **Additional Properties Type**: string

## FoosResponse
### Properties
* **someString**: string (ReadOnly): The foo response string

## FoosRequest
### Properties
* **someString**: string (Required, WriteOnly): The foo request string

## FoosResponse
### Properties
* **someString**: string (ReadOnly): The foo response string