swagger-api / swagger-api/swagger-codegen

Identify specific operations

Open
#6,787 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hello, for latest version we are using a custom mustache template to generate code for rest controller, using Swagget-Code-gen we identify GET, POST, etc with:"isRestfulCreate","isRestfulIndex","isRestfulShow" variables.

Using the command below:
java -jar swagger-codegen-cli.jar generate -i customerManagement_v2.1.1.json -l spring -o samples/server/CustomerManager -t ../Templates/JavaSpring/ -DdateLibrary=joda

Swagger-Code-Gen mustache variables (isRestfulCreate,isRestfulIndex,isRestfulShow,etc) are not loading propertyly for this operations:

  1. -Operation: GET /customers/{customerId}/creditInfo
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  2. -Operation: GET /accounts/{accountId}/productOrders
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  3. -Operation:POST /accounts/{accountId}/productOrders
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  4. -Operation:GET /accounts/{accountId}/productOrders/{orderId}
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  5. -Operation: PUT /accounts/{accountId}/productOrders/{orderId}
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  6. -Operation: GET /accounts/{accountId}/productOrders/{orderId}/status
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

  7. -Operation: PUT /accounts/{accountId}/productOrders/{orderId}/status
    -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

As you can see all swagger code gen resolved all operations with false. We need to identify this suboperations of GET or PUT with new variables for aply custom templates.
Is there any way of identify this operations from swagger code gen correctly and generate our own custom code in mustache via {{>subGet}} or {{>subPut}}.

THX for this great tool!!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generation command with the customerManagement_v2.1.1.json input and the custom templates in ../Templates/JavaSpring/. Inspect how the Java Spring generator exposes operation variables to Mustache, focusing on the listed nested GET and PUT paths. Done means the relevant suboperations receive usable template variables and the generated custom code distinguishes them.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.