LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

GET and MULTIGET pluralize issue with resources ending in "s" #52

Closed michael-gillett closed 4 years ago

michael-gillett commented 4 years ago

Overview

If you have GET and MULTIGET operations on a resource that ends in "s" the generated swagger has the same operationId for both actions while violates a constraint of swagger.

Did some quick digging in the code and the issue appears to be the pluralizeName function in src/names.ts

It returns the name unaltered if it already ends in "s" which leads to this issue.

Reproduce

namespace test {
    title "Test"
    version 1.0.0
}

resource status {
  id: int

  /operations
  GET MULTIGET
}

The operationId in the generated swagger will be "Get status" for both operations

michael-gillett commented 4 years ago

One option would be to break out the big guns https://www.npmjs.com/package/pluralize

liveandrew commented 4 years ago

eek, apologies. having a look now

liveandrew commented 4 years ago

fixed in 1.4.5 - 46fe0ed50fa71854d73e154b080a054cf02cecf5

liveandrew commented 4 years ago

@michael-gillett i rethought this and used the pluralize() module. thanks for the link - /v1/people looks better than /v1/persons ;-P

liveandrew commented 4 years ago

hmm am hoping i didn't introduce any breaking API changes by doing this...

npoulallion commented 4 years ago

@liveandrew might make sense to make an announcement on #dev-api about this? Let me know if you want me to take care of it

liveandrew commented 4 years ago

yes please nicolas, that would be great

liveandrew commented 4 years ago

btw i think it affects relatively few resources, that's certainly my hope