[BUG] API's with revisions are not being set to current.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 448
- Forks
- 247
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### Release version
6.0.1.1
### Describe the bug
The publishing of our APIM artifacts is failing once there's a reference to an API operation that only exists in the parent APIs second revision, even though the second revision should be the current revision. Looking at the APIs in Azure, I see that the first revision is set as current even though the APIs `apiInformation.json` file has it's `isCurrent` property set to `true`.
From what I can tell, looking at the code, the `isCurrent` value is being nulled out of the API `Dto` object to prevent occasional failures.

This causes the API to be initially deployed with out the `isCurrent` property set, defaulting to revision 1 as current.
I then noticed that there's a process in place to "correct" the revision number: `CorrectApimRevisionNumber`.
But, reviewing that code, I think I found a small bug preventing that process from correcting the revision numbers of revisioned APIs.

I could be wrong, but it appears that this would skip all revisioned APIs when assessing them for correction.
To test this, I cloned the repo and updated line [369](https://github.com/Azure/apiops/blob/b9c4361598d20b11d24662c7eced93617725d61e/tools/code/publisher/Api.cs#L369) to:
```cs
if (ApiName.IsNotRevisioned(name))
```
After that, I ran it locally and it published successfully.
### Expected behavior
I expect API revisions to be set correctly in accordance to the API's `apiInformation.json` file.
### Actual behavior
Revisioned APIs do not have the correct revision set to current after deployment, causing failures when anything in the now non-current API is referenced.
### Reproduction Steps
In a new APIM instance:
1. Create an API with a single operation.
2. Revision the API.
3. Create another operation in that new revision.
4. Set the second revision as current (`Make current`).
5. Extract the APIM instance.
6. Delete all APIs or create another new APIM instance.
7. Publish the extracted artifacts to the cleaned or new APIM instance.
You should see that revision 1 is incorrectly set as current.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit tools/code/publisher/Api.cs in der Nähe von Zeile 369 und verfolgen Sie CorrectApimRevisionNumber, indem Sie dessen Revisionsprüfung mit dem Wert isCurrent von apiInformation.json der API vergleichen. Reproduzieren Sie den beschriebenen Azure APIM-Extraktions- und Veröffentlichungsablauf und überprüfen Sie anschließend, dass die im Artefakt als aktuell markierte Revision nach der Bereitstellung weiterhin aktuell ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- azure, csharp
- Bereich
- api, cloud
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100