Skip to content

[csharp-netcore] Update to fix the issue for client not generated when modelOneOf of array of string #13254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

prajon84
Copy link
Contributor

@prajon84 prajon84 commented Aug 22, 2022

This PR address fixes the issue for csharp-netcore generator in which clients were not being generated if format: string is not specified.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328 @devhl-labs @Blackclaws @jafin @jfeltesse-mdsol @bgong-mdsol @ykitamura-mdsol

@jafin
Copy link
Contributor

jafin commented Aug 23, 2022

Hi @prajon84 Are you able to amend the example to omit the type: string to confirm this fix?
From the PR I can't easily see how the change fixes the issue being described.
All I see is a change in the casing of the method name from being TitleCase to to not Titlecase ?

@prajon84
Copy link
Contributor Author

@jafin : Yeah I do not know why in the e.g. in the code base only TitleCase changed to Titlecase. But, I have tried locally.

For. e.g.

  1. for openapi spec without format: string
openapi: 3.0.3
info:
  title: C# Object with oneof array of string
  version: v1
paths:
  '/hello':
    get:
      responses:
        '200':
          description: returns polymorphic property
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolymorphicProperty'

components:
  schemas:
    PolymorphicProperty:
      description: Comparison information
      oneOf:
        - type: boolean
        - type: string
        - type: object
        - type: array
          items:
            $ref: '#/components/schemas/StringArrayItem'
    StringArrayItem:
      type: string

The client got generated properly which was the problem before.
image

And, the client build too:
image

  1. for openapi spec with format: string
openapi: 3.0.3
info:
  title: C# Object with oneof array of string
  version: v1
paths:
  '/hello':
    get:
      responses:
        '200':
          description: returns polymorphic property
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolymorphicProperty'

components:
  schemas:
    PolymorphicProperty:
      description: Comparison information
      oneOf:
        - type: boolean
        - type: string
        - type: object
        - type: array
          items:
            $ref: '#/components/schemas/StringArrayItem'
    StringArrayItem:
      type: string
      format: string

It generates and builds perfectly too:
image

image

@ykitamura-mdsol
Copy link
Contributor

We just followed the same pattern as in this file:

{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}};

@prajon84
Copy link
Contributor Author

Can @jafin @wing328 review and merge this please 🙏 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants