Coder Social home page Coder Social logo

Comments (12)

jbadeau avatar jbadeau commented on August 20, 2024

Its is fixed with:

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen</artifactId>
            <version>2.1.4</version>
        </dependency>

any chance of a release using the latest swagger-codegen?

from swagger-codegen-tooling.

jbellmann avatar jbellmann commented on August 20, 2024

hi @jbadeau,

please try out this release, 0.4.17. Its updated to latest swagger-codegen. Let me know if it works or any trouble you have.

Cheers
Jörg

from swagger-codegen-tooling.

jbadeau avatar jbadeau commented on August 20, 2024

Hi, thank you very much for the release. Unfortunately it did not solve the model problem but it solved some other ones. I tried the official io.swagger generator and it works fine for model generation. I see that your change pulls in the correct version so I'm at a loss as to why it doesn't work. I will investigate the cause and report back. Thank you for such a fast response.

from swagger-codegen-tooling.

ePaul avatar ePaul commented on August 20, 2024

This project has its own templates ... so it could be that the templates here in the repository have to be updated too.

Which output format ("language" parameter) are you using?

from swagger-codegen-tooling.

jbadeau avatar jbadeau commented on August 20, 2024

My setup where ${swagger-codegen.version} = 0.4.17

<plugin>
                <groupId>org.zalando.maven.plugins</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate rest api</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>codegen</goal>
                        </goals>
                        <configuration>
                            <apiFile>${project.basedir}/src/main/resources/swagger/sopid/swagger.yaml</apiFile>
                            <language>springinterfacesResponseEntity</language>
                            <apiPackage>com.abc.h6x.offerings.sopid.web</apiPackage>
                            <modelPackage>com.abc.h6x.offerings.sopid.web.resource</modelPackage>
                            <enableBuilderSupport>true</enableBuilderSupport>
                            <enable303>true</enable303>
                            <outputDirectory>${basedir}/src/main/java-gen</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.zalando.stups</groupId>
                        <artifactId>swagger-codegen-template-spring-interfaces</artifactId>
                        <version>${swagger-codegen.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

I just noticed that you have your own model template. I assumed you where delegating to the io.swagger DefaultGenerator. Oops!

Comparing:

https://github.com/zalando-stups/swagger-codegen-tooling/blob/master/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache

to:
https://github.com/zalando-stups/swagger-codegen-tooling/blob/master/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache

The output for the fields is a bit different in the latest io.swagger template. Don't know enough about the template logic to comment though.

from swagger-codegen-tooling.

jbellmann avatar jbellmann commented on August 20, 2024

@jbadeau

can you please verify this with 0.4.20.

Yes we delegate as much as possible to the original-codegenerator. And we only had some fixes for issues in their code. But it seems they put a lot of fixes into their own codebase. Good for us, we can remove our code ;-).

Please close this issue if everything is working or let use know the issues to fix this asap.

Cheers
Jörg

from swagger-codegen-tooling.

jbadeau avatar jbadeau commented on August 20, 2024

I already left work but I'll check it first thing tomorrow.

from swagger-codegen-tooling.

jbellmann avatar jbellmann commented on August 20, 2024

@jbadeau

Any news for me on this issue? Is it working as expected?

from swagger-codegen-tooling.

jbadeau avatar jbadeau commented on August 20, 2024

Very sorry for the late response. I ended up having to go to China for a while :O. Unfortunately 0.4.20 does not produce the correct results.

Given:

productComponentValueCd:
    type: object
    additionalProperties:
        type: string

produces:

private String productComponentValueCd = null;

but should produce:

private Map<String, String> productComponentValueCd = null;

from swagger-codegen-tooling.

jbellmann avatar jbellmann commented on August 20, 2024

Hi @jbadeau,

hope you enjoyed china.

Thanks for your feedback but I'm wondering why it does not work for you. For me it does. So I created an integration-test with a configuration similar to yours here. So it's in the project now and you can verify it by your own. Just clone it or pull to get the latest version, change into the 'swagger-codegen-maven-plugin'-directory and run 'mvn clean install -Pintegration' (takes a while, many tests). I added your case to the 'Pet'-type in the swagger-definition. If the build has finished you find everything int 'target/it/issue_21/target/generated-sources/swagger-codegen/de/zalando/model/Pet.java'. Should be

private Map<String,String> test = new HashMap<String,String>();

also with 'getter/setter' for the field.

Please check that. If it does not work on your machine, could please provide a complete sample-swagger-definition with all the things in it you normally define. That would be really helpfull for me.

Thanks for your cooperation.
Jörg

from swagger-codegen-tooling.

jbadeau avatar jbadeau commented on August 20, 2024

Hi,

So your petstore example works in your project and it also works in mine but our stuff is not working.

The differences I see are:

  • we are using YAML instead of JSON (i only posted the issue in json to use code highlighting)
  • we have split the API and Resources into 2 files like: petstore-service-spec.yaml and petstore-resources.yaml

We reference the resources in the spec like:

  responses:
    '200':
      description: sopids response
      schema:
        type: array
        items:
          $ref: './petstore-resources#/Pet'

from swagger-codegen-tooling.

jbellmann avatar jbellmann commented on August 20, 2024

So, I will close this issue because generation for Model basically works as expected. The thing with splitted files goes into it's own issue (#23).

from swagger-codegen-tooling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.