Skip to content
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

Need help with server stub generation #12

Closed
ramrattle opened this issue Oct 27, 2022 · 3 comments
Closed

Need help with server stub generation #12

ramrattle opened this issue Oct 27, 2022 · 3 comments

Comments

@ramrattle
Copy link

Really appreciate taking time to create this repo, I have problem in generating stub for NRF, I just edited the pom.xml file to have only NRF but getting the following error, any help from you will be really appreciated

pom.xml file

python-flask ${project.build.directory}/generated-sources
            <executions>
                <execution>
                    <id>1</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>${project.basedir}/5GC_APIs/TS29510_Nnrf_NFDiscovery.yaml</inputSpec>
                        <modelPackage>com.h21lab.TS29510_Nnrf_NFDiscovery.handler</modelPackage>
                        <apiPackage>com.h21lab.TS29510_Nnrf_NFDiscovery.model</apiPackage>
                        <invokerPackage>com.h21lab.TS29510_Nnrf_NFDiscovery.handler</invokerPackage>
                    </configuration>
                </execution>
            </executions>

when I run the server stub, getting the below error

root@Focal:/home/generator/5GC_build/5GC_code_generator/target/generated-sources# python3 -m openapi_server
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/generator/5GC_build/5GC_code_generator/target/generated-sources/openapi_server/main.py", line 19, in
main()
File "/home/generator/5GC_build/5GC_code_generator/target/generated-sources/openapi_server/main.py", line 11, in main
app.add_api('openapi.yaml',
File "/usr/local/lib/python3.8/dist-packages/connexion/apps/flask_app.py", line 72, in add_api
api = super().add_api(specification, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/connexion/apps/abstract.py", line 149, in add_api
api = self.api_cls(specification,
File "/usr/local/lib/python3.8/dist-packages/connexion/apis/abstract.py", line 81, in init
self.specification = Specification.load(specification, arguments=arguments)
File "/usr/local/lib/python3.8/dist-packages/connexion/spec.py", line 194, in load
return cls.from_file(spec, arguments=arguments)
File "/usr/local/lib/python3.8/dist-packages/connexion/spec.py", line 148, in from_file
return cls.from_dict(spec)
File "/usr/local/lib/python3.8/dist-packages/connexion/spec.py", line 186, in from_dict
return OpenAPISpecification(spec)
File "/usr/local/lib/python3.8/dist-packages/connexion/spec.py", line 74, in init
self._validate_spec(raw_spec)
File "/usr/local/lib/python3.8/dist-packages/connexion/spec.py", line 92, in _validate_spec
raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: {'content': {'application/json': {'schema': {'items': {'$ref': '#/components/schemas/PlmnId'}, 'minItems': 1, 'type': 'array'}}}, 'description': 'Id of the PLMN of the target NF', 'explode': True, 'in': 'query', 'name': 'target-plmn-list', 'required': False, 'style': 'form'} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:
{'oneOf': [{'$ref': '#/definitions/Parameter'},
{'$ref': '#/definitions/Reference'}]}

On instance['paths']['/nf-instances']['get']['parameters'][6]:
{'content': {'application/json': {'schema': {'items': {'$ref': '#/components/schemas/PlmnId'},
'minItems': 1,
'type': 'array'}}},
'description': 'Id of the PLMN of the target NF',
'explode': True,
'in': 'query',
'name': 'target-plmn-list',
'required': False,
'style': 'form'}

The same works for the N32 handshake that is present in your default pom without any changes but anything other than that is failing

@H21lab
Copy link
Owner

H21lab commented Oct 27, 2022

Thank you for reporting this. Unfortunately not all OpenAPI generators are according to the latest OpenAPI specification. You can see this in issue #11. Maybe you can try to use different generator like jersey2 library, however very likely you will run into similar problems, once you will try to compile complex 5G yaml file.

I would recommend to read this issue jdegre/5GC_APIs#17. And if you do need to implement the whole Network Function you can see these slides with HTTP/2 client python code on it. I hope this could help.

@ramrattle
Copy link
Author

@H21lab thanks for replying, really appreciate it, I ran into same problem with new Yaml and generators as well,
jdegre/5GC_APIs#51 , have you seen anyone able to create the stub with generators? Is python the problem here?

@H21lab
Copy link
Owner

H21lab commented Oct 27, 2022

Java jersey2 generator is probably more advanced. However when I was testing it in past it was failing on certain syntax too.

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

No branches or pull requests

2 participants