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

feat!: generate models for OpenAPI parameters #1498

Merged
merged 4 commits into from
Sep 5, 2023

Conversation

dlkj
Copy link
Contributor

@dlkj dlkj commented Sep 4, 2023

Description
Models that were only present in OpenAPIV3 parameters were not being generated. This was causing problems for parameters with schema like enum that can be reflected in the language type system.

@netlify
Copy link

netlify bot commented Sep 4, 2023

Deploy Preview for modelina ready!

Name Link
🔨 Latest commit b21c87b
🔍 Latest deploy log https://app.netlify.com/sites/modelina/deploys/64f6fd2d24ca9800084a2255
😎 Deploy Preview https://deploy-preview-1498--modelina.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dlkj dlkj changed the title feat!: Generate models for OpenAPI parameters feat!: generate models for OpenAPI parameters Sep 4, 2023
@dlkj
Copy link
Contributor Author

dlkj commented Sep 4, 2023

Adding a more explicit unit test to test/processors/OpenAPIInputProcessor.spec.ts has turned out to be a fiddly as there are no models in the processed InputMetaModel due to the mocked Interpreter.

@dlkj dlkj marked this pull request as draft September 5, 2023 08:36
@dlkj
Copy link
Contributor Author

dlkj commented Sep 5, 2023

Converting to draft - I've now got my head round how to write a more targeted unit test defending this change. Will convert back to a full PR once I have added it.

@sonarcloud
Copy link

sonarcloud bot commented Sep 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dlkj
Copy link
Contributor Author

dlkj commented Sep 5, 2023

Added an explicit unit test and fixed up the schema naming, ready for review now.

@dlkj dlkj marked this pull request as ready for review September 5, 2023 10:07
Comment on lines +175 to +182
private iterateParameters(
parameters:
| (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[]
| undefined,
path: string,
inputModel: InputMetaModel,
options?: ProcessorOptions
) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont want to introduce an option so the user can specify whether they want to include parameters or not? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters are just as much part of the OpenAPI spec as the requests and responses, so I don't see much of a use case in having them as an option. The extra cost is minimal. Happy to add one if you have strong views. I don't see anything similar on ProcessorOptions for other document formats.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats because in for example AsyncAPI input processor, we only generate message payloads, not parameters, even though we probably should allow it in some way (probably through options) 😄

But no I dont have any strong feelings for the OpenAPI input, so here it's fine 😄

@jonaslagoni
Copy link
Sponsor Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 32e156f into asyncapi:next Sep 5, 2023
28 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-next.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

jonaslagoni added a commit that referenced this pull request Oct 17, 2023
* fix!: use preferred ids over anonymous ids (#1099)

* chore(release): v2.0.0-next.1 (#1113)

* fix!: adds union type when operation.message.oneOf is set (#1136)

* chore(release): v2.0.0-next.2 (#1144)

* chore(release): v2.0.0-next.3 (#1146)

* fix!: additionalItems being applied for regular arrays (#1140)

* chore(release): v2.0.0-next.4 (#1151)

* test: upgrades eslint and adds eslint-plugin-jest (#1166)

* fix!: fixes required properties when if/then/else is used (#1149)

* chore(release): v2.0.0-next.5 (#1184)

* chore: update snapshot and packagelock

* chore: update snapshot of example

* feat: force release (#1221)

* chore(release): v2.0.0-next.6 (#1222)

* feat!: handle const and discriminator (#1169)

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* fixes bug when using oneOf in channel by not adding models to input model if they have already been scanned

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: handle const

* feat: set correct java quotes

* remove discriminator from CommonModel because we don't need it

* remove discriminator from CommonModel because we don't need it

* fixes review comments

* adds constant constrainers

* adds constant constrainers

* adds constant constrainers

* adds constant constrainers

* remove unused var

* chore(release): v2.0.0-next.7 (#1242)

* fix!: should not carry over options from metaModel to constrainedModel (#1243)

* chore(release): v2.0.0-next.8 (#1247)

* docs: fixes constant constraints documentation (#1241)

* refactor: adds discriminator in CommonModel and interpreters (#1269)

* refactor: adds discriminator in CommonModel and interpreters

* refactor: adds discriminator in CommonModel and interpreters

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel (#1270)

* refactor: adds discriminator in CommonModel and interpreters

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* fix test

* review fix

* fix!: update default Kotlin renderer to make non-required properties nullable (#1277)

* chore(release): v2.0.0-next.9 (#1278)

* feat!: adds interface for oneOf objects for Java (#1271)

* refactor: adds discriminator in CommonModel and interpreters

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* feat: adds interface for oneOf objects for Java

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* update snapshot

* refactor: adds discriminator in MetaModel and ConstrainedMetaModel

* fix test

* feat: adds interface for oneOf objects for Java

* Revert "feat: adds interface for oneOf objects for Java"

This reverts commit e7bd8fb.

* review fix

* merge fix

* adds tests

* adds documentation

* fixes docs

* Update docs/migrations/version-1-to-2.md

Co-authored-by: Daniel KJ <github@dlkj.co.uk>

* adds test for union without jackson preset

* fixes docs

* fixes docs

* fixes docs

---------

Co-authored-by: Daniel KJ <github@dlkj.co.uk>

* chore(release): v2.0.0-next.10 (#1279)

* chore: update Rust union render to use ConstrainedMetaModelOptionsDiscriminator (#1282)

Update Rust union render to use `ConstrainedMetaModelOptionsDiscriminator`

Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* fix wrong import

* Revert "fix wrong import"

This reverts commit b6c5be6.

* fix: wrong import for Java preset (#1283)

fix: wrong import

* chore(release): v2.0.0-next.11 (#1286)

* feat!: add discriminator support for OpenAPI v3 and Swagger v2 (#1281)


Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* chore(release): v2.0.0-next.12 (#1287)

* feat!: use EXISTING_PROPERTY as JsonTypeInfo.As annotation to avoid duplicates when serializing (#1290)

* chore(release): v2.0.0-next.13 (#1291)

* chore: blackbox tests (#1303)


Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* feat!: enable nullable models (#1141)

* chore(release): v2.0.0-next.14 (#1313)

* chore: update new generators with next syntax

* chore: fix linting problem

* feat!: add java oneOf union support for properties of models  (#1296)


Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* chore: update dependency

* feat: update dependencies

* feat: update dependencies

* feat: update dependencies

* feat: trigger release and update dependencies (#1428)

* ci: temporarily enable release for next (#1430)

* fix: ts/js unmarshalling function bug (#1429)

* fix!: support java nullable double type (#1439)

Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* feat: update release configuration and trigger release (#1467)

* chore(release): v2.0.0-next.15 (#1468)

* feat: make discriminator property visible to deserializer from Java Jackson preset (#1469)


Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* chore(release): v2.0.0-next.16 (#1470)

* fix: typescript interface variable assignment (#1472)


Co-authored-by: Kristupas Narkeliunas <kristupas.narkeliun@ihsmarkit.com>

* chore(release): v2.0.0-next.17 (#1473)

* feat!: upgrade to node 18 (#1422)

* upgrade to v18

* adapt rest of workflows

* update readme

* recommit packagelock

* feat!: supports optional properties in java (#1485)

* chore(release): v2.0.0-next.18 (#1487)

* chore: add next integration example (#1488)

* fix: adds format in options instead of using original input (#1486)

* chore(release): v2.0.0-next.19 (#1492)

* feat!: generate models for OpenAPI parameters (#1498)


Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>

* chore(release): v2.0.0-next.20 (#1500)

* fix: fixes java jackson discriminator when property is not camel case (#1502)

* chore(release): v2.0.0-next.21 (#1504)

* fix: fixes performance issues in java when calling parent unions (#1501)

* chore(release): v2.0.0-next.22 (#1506)

* feat!: refactors generators to use the same arg types (#1505)

* chore(release): v2.0.0-next.23 (#1507)

* fix: escape java string literals used for regex patterns and string constants (#1509)


Co-authored-by: Daniel Kenyon-Jones <kenyonjd@featurespace.co.uk>

* chore(release): v2.0.0-next.24 (#1558)

* chore: update linting and dev dependency versions

* chore: update migration guide (#1560)

* chore(release): v2.0.0-next.25 (#1571)

---------

Co-authored-by: Kenneth Aasan <k.aasan@sportradar.com>
Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io>
Co-authored-by: Cyprian Gracz <cyprian.gracz@micro-jumbo.eu>
Co-authored-by: Daniel KJ <github@dlkj.co.uk>
Co-authored-by: Daniel Kenyon-Jones <daniel.kenyon-jones@featurespace.co.uk>
Co-authored-by: Kristupas <53404771+Ksisa@users.noreply.github.com>
Co-authored-by: Kristupas Narkeliunas <kristupas.narkeliun@ihsmarkit.com>
Co-authored-by: Daniel Kenyon-Jones <kenyonjd@featurespace.co.uk>
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.

None yet

4 participants