Skip to content

Commit

Permalink
Don't generate an empty constants file (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhendrixMSFT authored Mar 9, 2023
1 parent 13e66f6 commit a547e23
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/generator/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ async function getModuleVersion(session: Session<CodeModel>): Promise<string> {

// Creates the content in constants.go
export async function generateConstants(session: Session<CodeModel>): Promise<string> {
const enums = getEnums(session.model.schemas);
// lack of operation groups indicates model-only mode.
if (length(session.model.operationGroups) === 0) {
if (length(session.model.operationGroups) === 0 || (enums.length === 0 && !session.model.language.go!.host && !session.model.language.go!.azureARM)) {
return '';
}
let text = await contentPreamble(session);
Expand All @@ -38,7 +39,7 @@ export async function generateConstants(session: Session<CodeModel>): Promise<st
text += `\tmoduleVersion = "v${version}"\n`;
text += ')\n\n';
}
for (const enm of values(getEnums(session.model.schemas))) {
for (const enm of values(enums)) {
if (enm.desc) {
text += `${comment(`${enm.name} - ${enm.desc}`, '// ', undefined, commentLength)}\n`;
}
Expand Down
10 changes: 0 additions & 10 deletions test/autorest/custombaseurlgroup/zz_constants.go

This file was deleted.

10 changes: 0 additions & 10 deletions test/autorest/morecustombaseurigroup/zz_constants.go

This file was deleted.

0 comments on commit a547e23

Please sign in to comment.